@archbase/security 4.0.37 → 4.0.39

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.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import "reflect-metadata";
2
2
  import * as I from "inversify";
3
- import { decorate as xt, injectable as kt } from "inversify";
4
- import { compressString as St, decompressString as It, IOCContainer as Pt, ARCHBASE_IOC_API_TYPE as G, processErrorMessage as ee, IsNotEmpty as J, IsOptional as re, IsBoolean as q, IsEmail as Tt, getKeyByEnumValue as Ve, useArchbasePasswordRemember as Ct, getI18nextInstance as S, useArchbaseTheme as Ut, isEmailValidate as _t, useArchbaseAppContext as Dt } from "@archbase/core";
5
- import F from "crypto-js";
6
- import { jwtDecode as Rt } from "jwt-decode";
7
- import { jsx as d, jsxs as R, Fragment as te } from "react/jsx-runtime";
8
- import Ge, { useState as f, useEffect as z, createContext as Re, useMemo as Je, useRef as Ke, useCallback as pe, useContext as Ne } from "react";
9
- import { BehaviorSubject as ze } from "rxjs";
10
- import { ArchbaseRemoteApiService as ce, useArchbaseStore as qe } from "@archbase/data";
11
- import { v4 as K } from "uuid";
12
- import { Card as Ye, Text as se, Divider as ye, Group as we, Select as Nt, Tooltip as Bt, Button as ie, TextInput as Ce, Loader as Xe, PasswordInput as Ue, Checkbox as Mt, Anchor as Ot, useMantineColorScheme as Lt, Box as $t, Stack as jt, Skeleton as fe } from "@mantine/core";
13
- import { useFocusTrap as Qe } from "@mantine/hooks";
14
- import { IconCopy as Ft } from "@tabler/icons-react";
15
- import { ArchbaseDialog as We } from "@archbase/components";
16
- import { useContainer as ve } from "inversify-react";
17
- class Ze {
3
+ import { decorate as Nt, injectable as Bt } from "inversify";
4
+ import { compressString as Mt, decompressString as Ot, IOCContainer as Lt, ARCHBASE_IOC_API_TYPE as Y, processErrorMessage as ie, IsNotEmpty as q, IsOptional as ce, IsBoolean as ee, IsEmail as $t, getKeyByEnumValue as Ye, useArchbasePasswordRemember as zt, getI18nextInstance as A, useArchbaseTheme as jt, isEmailValidate as Ft, useArchbaseAppContext as Vt } from "@archbase/core";
5
+ import H from "crypto-js";
6
+ import { jwtDecode as Wt } from "jwt-decode";
7
+ import { jsx as n, jsxs as k, Fragment as re } from "react/jsx-runtime";
8
+ import st, { useState as m, useEffect as J, createContext as ze, useMemo as ot, useRef as nt, useCallback as ke, useContext as je } from "react";
9
+ import { BehaviorSubject as qe } from "rxjs";
10
+ import { ArchbaseRemoteApiService as pe, useArchbaseStore as it } from "@archbase/data";
11
+ import { v4 as X } from "uuid";
12
+ import { Card as Fe, Text as $, Divider as Pe, Stack as we, TextInput as ve, Button as V, Anchor as Xe, Group as ae, Select as Ht, Tooltip as Gt, Loader as at, PasswordInput as Oe, Checkbox as Jt, Alert as Qe, Code as Ze, CopyButton as et, SimpleGrid as Kt, useMantineColorScheme as Yt, Box as qt, Skeleton as Se } from "@mantine/core";
13
+ import { useFocusTrap as ct } from "@mantine/hooks";
14
+ import { IconCopy as Xt } from "@tabler/icons-react";
15
+ import { ArchbaseQRCode as Qt, ArchbaseDialog as tt } from "@archbase/components";
16
+ import { useContainer as Te } from "inversify-react";
17
+ class lt {
18
18
  id;
19
19
  displayName;
20
20
  email;
@@ -24,10 +24,10 @@ class Ze {
24
24
  this.id = e.id, this.displayName = e.displayName, this.email = e.email, this.photo = e.photo, this.isAdmin = e.isAdmin;
25
25
  }
26
26
  static newInstance() {
27
- return new Ze({});
27
+ return new lt({});
28
28
  }
29
29
  }
30
- class et {
30
+ class dt {
31
31
  username;
32
32
  password;
33
33
  remember;
@@ -35,16 +35,16 @@ class et {
35
35
  this.username = e.username, this.password = e.password, this.remember = e.remember;
36
36
  }
37
37
  static newInstance() {
38
- return new et({});
38
+ return new dt({});
39
39
  }
40
40
  }
41
- const Q = "YngzI1guK3dGaElFcFY9MywqK3xgPzg/Ojg7eD8xRmg=", Se = "c1ab58e7-c113-4225-a190-a9e59d1207fc", Ie = "6faf6932-a0b5-457b-83b1-8d89ddbd91fd", Pe = "602b05c5-ec46-451e-aba6-187e463bc245", Te = "8b4a7c2d-9e5f-4163-b8a7-3f2c9d8e5a1b";
42
- class Vt {
41
+ const oe = "YngzI1guK3dGaElFcFY9MywqK3xgPzg/Ojg7eD8xRmg=", Re = "c1ab58e7-c113-4225-a190-a9e59d1207fc", Ne = "6faf6932-a0b5-457b-83b1-8d89ddbd91fd", Be = "602b05c5-ec46-451e-aba6-187e463bc245", Me = "8b4a7c2d-9e5f-4163-b8a7-3f2c9d8e5a1b";
42
+ class Zt {
43
43
  getUsernameAndPassword() {
44
44
  try {
45
- const e = localStorage.getItem(Ie);
45
+ const e = localStorage.getItem(Ne);
46
46
  if (e) {
47
- const t = F.AES.decrypt(e, Q).toString(F.enc.Utf8), o = atob(t).split(":");
47
+ const t = H.AES.decrypt(e, oe).toString(H.enc.Utf8), o = atob(t).split(":");
48
48
  return { username: o[0], password: o[1], remember: !0 };
49
49
  } else
50
50
  return null;
@@ -53,14 +53,14 @@ class Vt {
53
53
  }
54
54
  }
55
55
  saveUsernameAndPassword(e, t) {
56
- const s = btoa(`${e}:${t}`), o = F.AES.encrypt(s, Q).toString();
57
- localStorage.setItem(Ie, o);
56
+ const s = btoa(`${e}:${t}`), o = H.AES.encrypt(s, oe).toString();
57
+ localStorage.setItem(Ne, o);
58
58
  }
59
59
  getUsername() {
60
60
  try {
61
- const e = localStorage.getItem(Pe);
61
+ const e = localStorage.getItem(Be);
62
62
  if (e) {
63
- const t = F.AES.decrypt(e, Q).toString(F.enc.Utf8);
63
+ const t = H.AES.decrypt(e, oe).toString(H.enc.Utf8);
64
64
  return atob(t);
65
65
  } else
66
66
  return null;
@@ -69,15 +69,15 @@ class Vt {
69
69
  }
70
70
  }
71
71
  saveUsername(e) {
72
- const t = btoa(e), s = F.AES.encrypt(t, Q).toString();
73
- localStorage.setItem(Pe, s);
72
+ const t = btoa(e), s = H.AES.encrypt(t, oe).toString();
73
+ localStorage.setItem(Be, s);
74
74
  }
75
75
  isTokenExpired(e, t = 300) {
76
76
  let s = e;
77
77
  if (!s && !this.getToken())
78
78
  return !0;
79
79
  try {
80
- const o = Rt(s.access_token);
80
+ const o = Wt(s.access_token);
81
81
  if (!o)
82
82
  return !0;
83
83
  const c = Math.floor(Date.now() / 1e3), l = o.exp;
@@ -88,23 +88,23 @@ class Vt {
88
88
  }
89
89
  saveToken(e) {
90
90
  if (e) {
91
- const t = JSON.stringify(e), s = F.AES.encrypt(t, Q).toString(), o = St(s);
92
- localStorage.setItem(Se, o);
91
+ const t = JSON.stringify(e), s = H.AES.encrypt(t, oe).toString(), o = Mt(s);
92
+ localStorage.setItem(Re, o);
93
93
  } else
94
94
  this.clearToken();
95
95
  }
96
96
  clearUsernameAndPassword() {
97
- localStorage.removeItem(Ie), localStorage.removeItem(Pe);
97
+ localStorage.removeItem(Ne), localStorage.removeItem(Be);
98
98
  }
99
99
  clearToken() {
100
- localStorage.removeItem(Se);
100
+ localStorage.removeItem(Re);
101
101
  }
102
102
  getToken() {
103
103
  try {
104
- const e = localStorage.getItem(Se);
104
+ const e = localStorage.getItem(Re);
105
105
  if (!e)
106
106
  return null;
107
- const t = It(e), s = F.AES.decrypt(t, Q).toString(F.enc.Utf8);
107
+ const t = Ot(e), s = H.AES.decrypt(t, oe).toString(H.enc.Utf8);
108
108
  return JSON.parse(s);
109
109
  } catch {
110
110
  return null;
@@ -112,37 +112,37 @@ class Vt {
112
112
  }
113
113
  saveContext(e) {
114
114
  try {
115
- const t = F.AES.encrypt(e, Q).toString();
116
- localStorage.setItem(Te, t);
115
+ const t = H.AES.encrypt(e, oe).toString();
116
+ localStorage.setItem(Me, t);
117
117
  } catch (t) {
118
118
  console.warn("Erro ao salvar contexto:", t);
119
119
  }
120
120
  }
121
121
  getContext() {
122
122
  try {
123
- const e = localStorage.getItem(Te);
124
- return e ? F.AES.decrypt(e, Q).toString(F.enc.Utf8) : null;
123
+ const e = localStorage.getItem(Me);
124
+ return e ? H.AES.decrypt(e, oe).toString(H.enc.Utf8) : null;
125
125
  } catch {
126
126
  return null;
127
127
  }
128
128
  }
129
129
  clearContext() {
130
- localStorage.removeItem(Te);
130
+ localStorage.removeItem(Me);
131
131
  }
132
132
  }
133
- xt(kt(), Vt);
134
- function tt(r) {
133
+ Nt(Bt(), Zt);
134
+ function ut(r) {
135
135
  const t = new Uint8Array(1);
136
- return window.crypto.getRandomValues(t), t[0] >= Math.floor(256 / r) * r ? tt(r) : t[0] % r;
136
+ return window.crypto.getRandomValues(t), t[0] >= Math.floor(256 / r) * r ? ut(r) : t[0] % r;
137
137
  }
138
- function zt(r) {
138
+ function er(r) {
139
139
  let e = "";
140
140
  const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
141
141
  for (let s = 0; s < r; s++)
142
- e += t.charAt(tt(t.length - 1));
142
+ e += t.charAt(ut(t.length - 1));
143
143
  return e;
144
144
  }
145
- async function Wt(r) {
145
+ async function tr(r) {
146
146
  if (!window.crypto.subtle?.digest)
147
147
  throw new Error(
148
148
  "The context/environment is not secure, and does not support the 'crypto.subtle' module. See: https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle for details"
@@ -150,36 +150,36 @@ async function Wt(r) {
150
150
  const t = new TextEncoder().encode(r), s = await window.crypto.subtle.digest("SHA-256", t), o = String.fromCharCode(...new Uint8Array(s));
151
151
  return btoa(o).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
152
152
  }
153
- class rt extends Error {
153
+ class ht extends Error {
154
154
  status;
155
155
  statusText;
156
156
  constructor(e, t, s) {
157
157
  super(s), this.name = "FetchError", this.status = e, this.statusText = t;
158
158
  }
159
159
  }
160
- function Ht(r) {
160
+ function rr(r) {
161
161
  let e = "";
162
162
  return Object.entries(r).forEach(([t, s]) => {
163
163
  e += (e ? "&" : "") + t + "=" + encodeURIComponent(s);
164
164
  }), e;
165
165
  }
166
- async function Gt(r, e) {
166
+ async function sr(r, e) {
167
167
  return fetch(r, {
168
168
  method: "POST",
169
- body: Ht(e),
169
+ body: rr(e),
170
170
  headers: { "Content-Type": "application/x-www-form-urlencoded" }
171
171
  }).then(async (t) => {
172
172
  if (!t.ok) {
173
173
  const s = await t.text();
174
- throw new rt(t.status, t.statusText, s);
174
+ throw new ht(t.status, t.statusText, s);
175
175
  }
176
176
  return t;
177
177
  });
178
178
  }
179
- const st = "PKCE_code_verifier", _e = "ROCP_auth_state";
180
- async function Jt(r, e) {
181
- const t = zt(96);
182
- return sessionStorage.setItem(st, t), Wt(t).then((s) => {
179
+ const pt = "PKCE_code_verifier", Le = "ROCP_auth_state";
180
+ async function or(r, e) {
181
+ const t = er(96);
182
+ return sessionStorage.setItem(pt, t), tr(t).then((s) => {
183
183
  const o = new URLSearchParams({
184
184
  response_type: "code",
185
185
  client_id: r.clientId,
@@ -188,23 +188,23 @@ async function Jt(r, e) {
188
188
  code_challenge_method: "S256",
189
189
  ...r.extraAuthParameters
190
190
  });
191
- r.scope !== void 0 && o.append("scope", r.scope), sessionStorage.removeItem(_e);
191
+ r.scope !== void 0 && o.append("scope", r.scope), sessionStorage.removeItem(Le);
192
192
  const c = e ?? r.state;
193
- c && (sessionStorage.setItem(_e, c), o.append("state", c)), r?.preLogin && r.preLogin(), window.location.replace(`${r.authorizationEndpoint}?${o.toString()}`);
193
+ c && (sessionStorage.setItem(Le, c), o.append("state", c)), r?.preLogin && r.preLogin(), window.location.replace(`${r.authorizationEndpoint}?${o.toString()}`);
194
194
  });
195
195
  }
196
- function Kt(r) {
196
+ function nr(r) {
197
197
  return r.access_token !== void 0;
198
198
  }
199
- function ot(r, e) {
200
- return Gt(r, e).then((t) => t.json().then((s) => {
201
- if (Kt(s))
199
+ function mt(r, e) {
200
+ return sr(r, e).then((t) => t.json().then((s) => {
201
+ if (nr(s))
202
202
  return s;
203
203
  throw Error(s);
204
204
  }));
205
205
  }
206
- const qt = (r) => {
207
- const t = new URLSearchParams(window.location.search).get("code"), s = window.sessionStorage.getItem(st);
206
+ const ir = (r) => {
207
+ const t = new URLSearchParams(window.location.search).get("code"), s = window.sessionStorage.getItem(pt);
208
208
  if (!t)
209
209
  throw Error(`Parâmetro 'código' não encontrado na URL.
210
210
  A autenticação ocorreu?`);
@@ -221,8 +221,8 @@ A autenticação ocorreu?`);
221
221
  ...r.extraTokenParameters,
222
222
  ...r.extraAuthParams
223
223
  };
224
- return ot(r.tokenEndpoint, o);
225
- }, Yt = (r) => {
224
+ return mt(r.tokenEndpoint, o);
225
+ }, ar = (r) => {
226
226
  const { config: e, refreshToken: t } = r, s = {
227
227
  grant_type: "refresh_token",
228
228
  refresh_token: t,
@@ -231,65 +231,65 @@ A autenticação ocorreu?`);
231
231
  redirect_uri: e.redirectUri,
232
232
  ...e.extraTokenParameters
233
233
  };
234
- return ot(e.tokenEndpoint, s);
234
+ return mt(e.tokenEndpoint, s);
235
235
  };
236
- function Xt(r, e, t, s, o, c) {
236
+ function cr(r, e, t, s, o, c) {
237
237
  const l = new URLSearchParams({
238
238
  token: t || e,
239
239
  token_type_hint: t ? "refresh_token" : "access_token",
240
240
  client_id: r.clientId,
241
241
  post_logout_redirect_uri: r.logoutRedirect ?? r.redirectUri,
242
- ui_locales: window.navigator.languages.reduce((i, u) => i + " " + u),
242
+ ui_locales: window.navigator.languages.reduce((a, d) => a + " " + d),
243
243
  ...r.extraLogoutParameters
244
244
  });
245
245
  s && l.append("id_token_hint", s), o && l.append("state", o), c && l.append("logout_hint", c), window.location.replace(`${r.logoutEndpoint}?${l.toString()}`);
246
246
  }
247
- function Qt(r) {
248
- const e = r.get("state"), t = sessionStorage.getItem(_e);
247
+ function lr(r) {
248
+ const e = r.get("state"), t = sessionStorage.getItem(Le);
249
249
  if (e !== t)
250
250
  throw new Error(
251
251
  '"state" valor recebido do servidor de autenticação não corresponde à solicitação do cliente. Possível falsificação de solicitação entre sites'
252
252
  );
253
253
  }
254
- function Z(r, e, t) {
255
- const s = t === "session" ? sessionStorage : localStorage, [o, c] = f(() => {
256
- const i = s.getItem(r);
254
+ function ne(r, e, t) {
255
+ const s = t === "session" ? sessionStorage : localStorage, [o, c] = m(() => {
256
+ const a = s.getItem(r);
257
257
  try {
258
- return i ? JSON.parse(i) : e;
259
- } catch (u) {
258
+ return a ? JSON.parse(a) : e;
259
+ } catch (d) {
260
260
  return console.warn(
261
261
  `Falha ao analisar o valor armazenado para '${r}'.
262
262
  Continuando com o valor padrão.
263
- Error: ${u.message}`
263
+ Error: ${d.message}`
264
264
  ), e;
265
265
  }
266
- }), l = (i) => {
267
- if (i === void 0) {
268
- c(i), s.removeItem(r);
266
+ }), l = (a) => {
267
+ if (a === void 0) {
268
+ c(a), s.removeItem(r);
269
269
  return;
270
270
  }
271
271
  try {
272
- const u = i instanceof Function ? i(o) : i;
273
- c(u), s.setItem(r, JSON.stringify(u));
272
+ const d = a instanceof Function ? a(o) : a;
273
+ c(d), s.setItem(r, JSON.stringify(d));
274
274
  } catch {
275
- console.log(`Falha ao armazenar valor '${i}' para chave '${r}'`);
275
+ console.log(`Falha ao armazenar valor '${a}' para chave '${r}'`);
276
276
  }
277
277
  };
278
- return z(() => {
279
- const i = (u) => {
280
- u.storageArea === s && u.key === r && c(JSON.parse(u.newValue ?? ""));
278
+ return J(() => {
279
+ const a = (d) => {
280
+ d.storageArea === s && d.key === r && c(JSON.parse(d.newValue ?? ""));
281
281
  };
282
- return window.addEventListener("storage", i, !1), () => window.removeEventListener("storage", i, !1);
282
+ return window.addEventListener("storage", a, !1), () => window.removeEventListener("storage", a, !1);
283
283
  }), [o, l];
284
284
  }
285
- const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
285
+ const $r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
286
286
  __proto__: null,
287
- default: Z
287
+ default: ne
288
288
  }, Symbol.toStringTag, { value: "Module" }));
289
- function me(r) {
289
+ function Ie(r) {
290
290
  return ["", void 0, null].includes(r);
291
291
  }
292
- function Zt(r) {
292
+ function dr(r) {
293
293
  const {
294
294
  autoLogin: e = !0,
295
295
  clearURL: t = !0,
@@ -297,9 +297,9 @@ function Zt(r) {
297
297
  scope: o = void 0,
298
298
  preLogin: c = () => null,
299
299
  postLogin: l = () => null,
300
- onRefreshTokenExpire: i = void 0,
301
- storage: u = "local"
302
- } = r, m = {
300
+ onRefreshTokenExpire: a = void 0,
301
+ storage: d = "local"
302
+ } = r, y = {
303
303
  ...r,
304
304
  autoLogin: e,
305
305
  clearURL: t,
@@ -307,25 +307,25 @@ function Zt(r) {
307
307
  scope: o,
308
308
  preLogin: c,
309
309
  postLogin: l,
310
- onRefreshTokenExpire: i,
311
- storage: u
310
+ onRefreshTokenExpire: a,
311
+ storage: d
312
312
  };
313
- return er(m), m;
313
+ return ur(y), y;
314
314
  }
315
- function er(r) {
316
- if (me(r?.clientId))
315
+ function ur(r) {
316
+ if (Ie(r?.clientId))
317
317
  throw Error(
318
318
  "'clientId' deve ser definido no objeto 'ArchbaseAuthConfig' passado para ArchbaseAuthProvider"
319
319
  );
320
- if (me(r?.authorizationEndpoint))
320
+ if (Ie(r?.authorizationEndpoint))
321
321
  throw Error(
322
322
  "'authorizationEndpoint' deve ser definido no objeto 'ArchbaseAuthConfig' passado para ArchbaseAuthProvider"
323
323
  );
324
- if (me(r?.tokenEndpoint))
324
+ if (Ie(r?.tokenEndpoint))
325
325
  throw Error(
326
326
  "'tokenEndpoint' deve ser definido no objeto 'ArchbaseAuthConfig' passado para ArchbaseAuthProvider"
327
327
  );
328
- if (me(r?.redirectUri))
328
+ if (Ie(r?.redirectUri))
329
329
  throw Error(
330
330
  "'redirectUri' deve ser definido no objeto 'ArchbaseAuthConfig' passado para ArchbaseAuthProvider"
331
331
  );
@@ -337,23 +337,23 @@ function er(r) {
337
337
  "Usar 'extraAuthParams' e 'extraTokenParameters' não é recomendado. Eles fazem a mesma coisa e você deve usar apenas 'extraTokenParameters'"
338
338
  );
339
339
  }
340
- const ne = 600, oe = (r) => Math.round(Date.now() / 1e3 + r);
341
- function He(r) {
340
+ const ue = 600, de = (r) => Math.round(Date.now() / 1e3 + r);
341
+ function rt(r) {
342
342
  return Math.round(Date.now()) / 1e3 + 30 >= r;
343
343
  }
344
- const tr = [
344
+ const hr = [
345
345
  "refresh_expires_in",
346
346
  // KeyCloak
347
347
  "refresh_token_expires_in"
348
348
  // Azure AD
349
349
  ];
350
- function rr(r, e) {
351
- for (const t of tr)
350
+ function pr(r, e) {
351
+ for (const t of hr)
352
352
  if (t in e)
353
353
  return e[t];
354
- return e.refresh_token ? r + ne : r;
354
+ return e.refresh_token ? r + ue : r;
355
355
  }
356
- const ge = (r) => {
356
+ const Ce = (r) => {
357
357
  try {
358
358
  const t = r.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), s = decodeURIComponent(
359
359
  atob(t).split("").map(function(o) {
@@ -368,88 +368,88 @@ const ge = (r) => {
368
368
  Você pode desativar a decodificação JWT definindo o valor 'decodeToken' como 'falso' na configuração.`
369
369
  );
370
370
  }
371
- }, sr = Re({
371
+ }, mr = ze({
372
372
  token: "",
373
373
  login: () => null,
374
374
  logOut: () => null,
375
375
  error: null,
376
376
  loginInProgress: !1
377
- }), Cr = ({ authConfig: r, children: e }) => {
378
- const t = Je(() => Zt(r), [r]), [s, o] = Z(
377
+ }), zr = ({ authConfig: r, children: e }) => {
378
+ const t = ot(() => dr(r), [r]), [s, o] = ne(
379
379
  "ROCP_refreshToken",
380
380
  void 0,
381
381
  t.storage
382
- ), [c, l] = Z(
382
+ ), [c, l] = ne(
383
383
  "ROCP_refreshTokenExpire",
384
- oe(2 * ne),
384
+ de(2 * ue),
385
385
  t.storage
386
- ), [i, u] = Z("ROCP_token", "", t.storage), [m, b] = Z(
386
+ ), [a, d] = ne("ROCP_token", "", t.storage), [y, b] = ne(
387
387
  "ROCP_tokenExpire",
388
- oe(ne),
388
+ de(ue),
389
389
  t.storage
390
- ), [h, C] = Z(
390
+ ), [u, C] = ne(
391
391
  "ROCP_idToken",
392
392
  void 0,
393
393
  t.storage
394
- ), [E, y] = Z(
394
+ ), [v, g] = ne(
395
395
  "ROCP_loginInProgress",
396
396
  !1,
397
397
  t.storage
398
- ), [x, U] = Z(
398
+ ), [S, P] = ne(
399
399
  "ROCP_refreshInProgress",
400
400
  !1,
401
401
  t.storage
402
- ), [_, O] = f(), [D, N] = f(), [k, A] = f(null);
403
- let P;
404
- function W() {
405
- o(void 0), u(""), b(oe(ne)), l(oe(ne)), C(void 0), O(void 0), N(void 0), y(!1);
406
- }
407
- function L(p, n) {
408
- W(), A(null), t?.logoutEndpoint && Xt(t, i, s, h, p, n);
409
- }
410
- function B(p) {
411
- W(), y(!0);
412
- let n = p;
413
- p && typeof p != "string" && (console.warn(
414
- `O estado de login aprovado deve ser do tipo 'string'. Recebido'${p}'. Ignorando o valor...`
415
- ), n = void 0), Jt(t, n).catch((w) => {
416
- console.error(w), A(w.message), y(!1);
402
+ ), [B, R] = m(), [z, U] = m(), [h, w] = m(null);
403
+ let D;
404
+ function j() {
405
+ o(void 0), d(""), b(de(ue)), l(de(ue)), C(void 0), R(void 0), U(void 0), g(!1);
406
+ }
407
+ function F(f, i) {
408
+ j(), w(null), t?.logoutEndpoint && cr(t, a, s, u, f, i);
409
+ }
410
+ function N(f) {
411
+ j(), g(!0);
412
+ let i = f;
413
+ f && typeof f != "string" && (console.warn(
414
+ `O estado de login aprovado deve ser do tipo 'string'. Recebido'${f}'. Ignorando o valor...`
415
+ ), i = void 0), or(t, i).catch((E) => {
416
+ console.error(E), w(E.message), g(!1);
417
417
  });
418
418
  }
419
- function H(p) {
420
- u(p.access_token), o(p.refresh_token);
421
- const n = t.tokenExpiresIn ?? p.expires_in ?? ne;
422
- b(oe(n));
423
- const w = t.refreshTokenExpiresIn ?? rr(n, p);
424
- l(oe(w)), C(p.id_token);
419
+ function Q(f) {
420
+ d(f.access_token), o(f.refresh_token);
421
+ const i = t.tokenExpiresIn ?? f.expires_in ?? ue;
422
+ b(de(i));
423
+ const E = t.refreshTokenExpiresIn ?? pr(i, f);
424
+ l(de(E)), C(f.id_token);
425
425
  try {
426
- p.id_token && N(ge(p.id_token));
427
- } catch (a) {
428
- console.warn(`Falha ao decodificar idToken: ${a.message}`);
426
+ f.id_token && U(Ce(f.id_token));
427
+ } catch (p) {
428
+ console.warn(`Falha ao decodificar idToken: ${p.message}`);
429
429
  }
430
430
  try {
431
- t.decodeToken && O(ge(p.access_token));
432
- } catch (a) {
433
- console.warn(`Falha ao decodificar o token de acesso: ${a.message}`);
431
+ t.decodeToken && R(Ce(f.access_token));
432
+ } catch (p) {
433
+ console.warn(`Falha ao decodificar o token de acesso: ${p.message}`);
434
434
  }
435
435
  }
436
- function Y(p = !1) {
437
- return p || !t.onRefreshTokenExpire ? B() : t.onRefreshTokenExpire({ login: B });
436
+ function Z(f = !1) {
437
+ return f || !t.onRefreshTokenExpire ? N() : t.onRefreshTokenExpire({ login: N });
438
438
  }
439
- function $(p = !1) {
440
- if (i && He(m) && !(x && !p)) {
441
- if (He(c))
442
- return Y(p);
439
+ function K(f = !1) {
440
+ if (a && rt(y) && !(S && !f)) {
441
+ if (rt(c))
442
+ return Z(f);
443
443
  if (s) {
444
- U(!0), Yt({ config: t, refreshToken: s }).then((n) => H(n)).catch((n) => {
445
- if (n instanceof rt) {
446
- if (n.status === 400)
447
- return Y(p);
448
- console.error(n), A(n.message), p && B();
444
+ P(!0), ar({ config: t, refreshToken: s }).then((i) => Q(i)).catch((i) => {
445
+ if (i instanceof ht) {
446
+ if (i.status === 400)
447
+ return Z(f);
448
+ console.error(i), w(i.message), f && N();
449
449
  } else
450
- n instanceof Error && (console.error(n), A(n.message), p && B());
450
+ i instanceof Error && (console.error(i), w(i.message), f && N());
451
451
  }).finally(() => {
452
- U(!1);
452
+ P(!1);
453
453
  });
454
454
  return;
455
455
  }
@@ -458,55 +458,55 @@ const ge = (r) => {
458
458
  );
459
459
  }
460
460
  }
461
- z(() => (P = setInterval(() => $(), 1e4), () => clearInterval(P)), [i, s, c, m]);
462
- const X = Ke(!1);
463
- return z(() => {
464
- if (E) {
465
- const p = new URLSearchParams(window.location.search);
466
- if (!p.get("code")) {
467
- const n = p.get("error_description") || "Estado de autorização inválido. Atualizar a página pode resolver o problema.";
468
- console.error(n), A(n), L();
461
+ J(() => (D = setInterval(() => K(), 1e4), () => clearInterval(D)), [a, s, c, y]);
462
+ const se = nt(!1);
463
+ return J(() => {
464
+ if (v) {
465
+ const f = new URLSearchParams(window.location.search);
466
+ if (!f.get("code")) {
467
+ const i = f.get("error_description") || "Estado de autorização inválido. Atualizar a página pode resolver o problema.";
468
+ console.error(i), w(i), F();
469
469
  return;
470
470
  }
471
- if (!X.current) {
472
- X.current = !0;
471
+ if (!se.current) {
472
+ se.current = !0;
473
473
  try {
474
- Qt(p);
475
- } catch (n) {
476
- console.error(n), A(n.message);
474
+ lr(f);
475
+ } catch (i) {
476
+ console.error(i), w(i.message);
477
477
  }
478
- qt(t).then((n) => {
479
- H(n), t?.postLogin && t.postLogin();
480
- }).catch((n) => {
481
- console.error(n), A(n.message);
478
+ ir(t).then((i) => {
479
+ Q(i), t?.postLogin && t.postLogin();
480
+ }).catch((i) => {
481
+ console.error(i), w(i.message);
482
482
  }).finally(() => {
483
- t.clearURL && window.history.replaceState(null, "", window.location.pathname), y(!1);
483
+ t.clearURL && window.history.replaceState(null, "", window.location.pathname), g(!1);
484
484
  });
485
485
  }
486
486
  return;
487
487
  }
488
- if (!i && t.autoLogin)
489
- return B();
488
+ if (!a && t.autoLogin)
489
+ return N();
490
490
  try {
491
- h && N(ge(h));
492
- } catch (p) {
493
- console.warn(`Falha ao decodificar idToken: ${p.message}`);
491
+ u && U(Ce(u));
492
+ } catch (f) {
493
+ console.warn(`Falha ao decodificar idToken: ${f.message}`);
494
494
  }
495
495
  try {
496
- t.decodeToken && O(ge(i));
497
- } catch (p) {
498
- console.warn(`Falha ao decodificar o token de acesso: ${p.message}`);
496
+ t.decodeToken && R(Ce(a));
497
+ } catch (f) {
498
+ console.warn(`Falha ao decodificar o token de acesso: ${f.message}`);
499
499
  }
500
- $(!0);
501
- }, []), /* @__PURE__ */ d(
502
- sr.Provider,
500
+ K(!0);
501
+ }, []), /* @__PURE__ */ n(
502
+ mr.Provider,
503
503
  {
504
- value: { token: i, tokenData: _, idToken: h, idTokenData: D, login: B, logOut: L, error: k, loginInProgress: E },
504
+ value: { token: a, tokenData: B, idToken: u, idTokenData: z, login: N, logOut: F, error: h, loginInProgress: v },
505
505
  children: e
506
506
  }
507
507
  );
508
508
  };
509
- class nt {
509
+ class ft {
510
510
  resourceService;
511
511
  resource;
512
512
  actions;
@@ -515,7 +515,7 @@ class nt {
515
515
  error;
516
516
  isAdmin;
517
517
  constructor(e, t, s) {
518
- this.resourceService = Pt.getContainer().get(G.Resource), this.resource = { resourceName: e, resourceDescription: t }, this.alreadyApplied = !1, this.actions = [], this.permissions = [], this.error = "", this.isAdmin = s;
518
+ this.resourceService = Lt.getContainer().get(Y.Resource), this.resource = { resourceName: e, resourceDescription: t }, this.alreadyApplied = !1, this.actions = [], this.permissions = [], this.error = "", this.isAdmin = s;
519
519
  }
520
520
  registerAction(e, t) {
521
521
  !this.alreadyApplied && this.actions.findIndex((s) => s.actionName === e) < 0 && this.actions.push({ actionName: e, actionDescription: t });
@@ -524,7 +524,7 @@ class nt {
524
524
  this.alreadyApplied || (this.alreadyApplied = !0, this.resourceService.registerResource({ resource: this.resource, actions: this.actions }).then((t) => {
525
525
  this.permissions = t.permissions, this.error = "", e && e();
526
526
  }).catch((t) => {
527
- this.alreadyApplied = !1, this.error = ee(t);
527
+ this.alreadyApplied = !1, this.error = ie(t);
528
528
  }));
529
529
  }
530
530
  hasPermission(e) {
@@ -586,10 +586,10 @@ class nt {
586
586
  return [...this.actions];
587
587
  }
588
588
  }
589
- class V {
589
+ class G {
590
590
  static instance;
591
- _currentTenant = new ze(null);
592
- _availableTenants = new ze([]);
591
+ _currentTenant = new qe(null);
592
+ _availableTenants = new qe([]);
593
593
  constructor() {
594
594
  const e = localStorage.getItem("tenant_info");
595
595
  if (e)
@@ -600,7 +600,7 @@ class V {
600
600
  }
601
601
  }
602
602
  static getInstance() {
603
- return V.instance || (V.instance = new V()), V.instance;
603
+ return G.instance || (G.instance = new G()), G.instance;
604
604
  }
605
605
  get currentTenant$() {
606
606
  return this._currentTenant.asObservable();
@@ -629,15 +629,15 @@ class V {
629
629
  return t && (e["X-TENANT-ID"] = t.id), e;
630
630
  }
631
631
  }
632
- function Ur() {
633
- return V.getInstance();
632
+ function jr() {
633
+ return G.getInstance();
634
634
  }
635
- var ae = /* @__PURE__ */ ((r) => (r.USER = "user", r.PROFILE = "profile", r.GROUP = "group", r))(ae || {}), or = Object.defineProperty, v = (r, e, t, s) => {
635
+ var he = /* @__PURE__ */ ((r) => (r.USER = "user", r.PROFILE = "profile", r.GROUP = "group", r))(he || {}), fr = Object.defineProperty, x = (r, e, t, s) => {
636
636
  for (var o = void 0, c = r.length - 1, l; c >= 0; c--)
637
637
  (l = r[c]) && (o = l(e, t, o) || o);
638
- return o && or(e, t, o), o;
639
- }, nr = /* @__PURE__ */ ((r) => (r.VIEW = "VIEW", r.API = "API", r))(nr || {});
640
- const it = class at {
638
+ return o && fr(e, t, o), o;
639
+ }, gr = /* @__PURE__ */ ((r) => (r.VIEW = "VIEW", r.API = "API", r))(gr || {});
640
+ const gt = class yt {
641
641
  id;
642
642
  code;
643
643
  version;
@@ -648,20 +648,20 @@ const it = class at {
648
648
  description;
649
649
  intervals;
650
650
  constructor(e) {
651
- this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || "", this.updateEntityDate = e.updateEntityDate || "", this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.description = e.description || "", this.intervals = e.intervals ? e.intervals.map((t) => new ir(t)) : [];
651
+ this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || "", this.updateEntityDate = e.updateEntityDate || "", this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.description = e.description || "", this.intervals = e.intervals ? e.intervals.map((t) => new yr(t)) : [];
652
652
  }
653
- static newInstance = () => new at({
654
- id: K(),
653
+ static newInstance = () => new yt({
654
+ id: X(),
655
655
  intervals: []
656
656
  });
657
657
  };
658
- v([
659
- J({
658
+ x([
659
+ q({
660
660
  message: "archbase:Informe a descrição do cronograma de acesso"
661
661
  })
662
- ], it.prototype, "description");
663
- let ct = it;
664
- const Ae = class lt {
662
+ ], gt.prototype, "description");
663
+ let wt = gt;
664
+ const Ue = class vt {
665
665
  id;
666
666
  code;
667
667
  version;
@@ -674,30 +674,30 @@ const Ae = class lt {
674
674
  startTime;
675
675
  endTime;
676
676
  constructor(e) {
677
- this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.updateEntityDate = e.updateEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.accessSchedule = e.accessSchedule ? new ct(e.accessSchedule) : void 0, this.dayOfWeek = e.dayOfWeek || 0, this.startTime = e.startTime || "", this.endTime = e.endTime || "";
677
+ this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.updateEntityDate = e.updateEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.accessSchedule = e.accessSchedule ? new wt(e.accessSchedule) : void 0, this.dayOfWeek = e.dayOfWeek || 0, this.startTime = e.startTime || "", this.endTime = e.endTime || "";
678
678
  }
679
- static newInstance = () => new lt({
680
- id: K(),
679
+ static newInstance = () => new vt({
680
+ id: X(),
681
681
  dayOfWeek: (/* @__PURE__ */ new Date()).getDay(),
682
682
  startTime: "08:00",
683
683
  endTime: "17:00"
684
684
  });
685
685
  };
686
- v([
687
- re()
688
- ], Ae.prototype, "accessSchedule");
689
- v([
690
- J({
686
+ x([
687
+ ce()
688
+ ], Ue.prototype, "accessSchedule");
689
+ x([
690
+ q({
691
691
  message: "archbase:Informe a hora de início"
692
692
  })
693
- ], Ae.prototype, "startTime");
694
- v([
695
- J({
693
+ ], Ue.prototype, "startTime");
694
+ x([
695
+ q({
696
696
  message: "archbase:Informe a hora de término"
697
697
  })
698
- ], Ae.prototype, "endTime");
699
- let ir = Ae;
700
- class le {
698
+ ], Ue.prototype, "endTime");
699
+ let yr = Ue;
700
+ class me {
701
701
  id;
702
702
  code;
703
703
  version;
@@ -712,20 +712,20 @@ class le {
712
712
  this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || "", this.updateEntityDate = e.updateEntityDate || "", this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.name = e.name || "", this.description = e.description || "", this.actions = e.actions || [];
713
713
  }
714
714
  }
715
- v([
716
- J({
715
+ x([
716
+ q({
717
717
  message: "archbase:Informe o nome"
718
718
  })
719
- ], le.prototype, "name");
720
- v([
721
- J({
719
+ ], me.prototype, "name");
720
+ x([
721
+ q({
722
722
  message: "archbase:Informe a descrição"
723
723
  })
724
- ], le.prototype, "description");
725
- v([
726
- re()
727
- ], le.prototype, "actions");
728
- const de = class dt {
724
+ ], me.prototype, "description");
725
+ x([
726
+ ce()
727
+ ], me.prototype, "actions");
728
+ const fe = class bt {
729
729
  id;
730
730
  code;
731
731
  version;
@@ -741,48 +741,48 @@ const de = class dt {
741
741
  actionVersion;
742
742
  isNewAction;
743
743
  constructor(e) {
744
- this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.updateEntityDate = e.updateEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.name = e.name || "", this.description = e.description || "", this.resource = e.resource ? new ht(e.resource) : void 0, this.category = e.category || "", this.active = e.active || !1, this.actionVersion = e.actionVersion || "", this.isNewAction = e.isNewAction || !1;
744
+ this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.updateEntityDate = e.updateEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.name = e.name || "", this.description = e.description || "", this.resource = e.resource ? new Et(e.resource) : void 0, this.category = e.category || "", this.active = e.active || !1, this.actionVersion = e.actionVersion || "", this.isNewAction = e.isNewAction || !1;
745
745
  }
746
- static newInstance = () => new dt({
747
- id: K(),
746
+ static newInstance = () => new bt({
747
+ id: X(),
748
748
  active: !0,
749
749
  isNewAction: !0
750
750
  });
751
751
  };
752
- v([
753
- J({
752
+ x([
753
+ q({
754
754
  message: "archbase:Informe o nome para a ação"
755
755
  })
756
- ], de.prototype, "name");
757
- v([
758
- J({
756
+ ], fe.prototype, "name");
757
+ x([
758
+ q({
759
759
  message: "archbase:Informe a descrição para a ação"
760
760
  })
761
- ], de.prototype, "description");
762
- v([
763
- re()
764
- ], de.prototype, "resource");
765
- v([
766
- J({
761
+ ], fe.prototype, "description");
762
+ x([
763
+ ce()
764
+ ], fe.prototype, "resource");
765
+ x([
766
+ q({
767
767
  message: "archbase:Informe a categoria para a ação"
768
768
  })
769
- ], de.prototype, "category");
770
- v([
771
- q()
772
- ], de.prototype, "active");
773
- let ar = de;
774
- class ue extends le {
769
+ ], fe.prototype, "category");
770
+ x([
771
+ ee()
772
+ ], fe.prototype, "active");
773
+ let wr = fe;
774
+ class be extends me {
775
775
  type;
776
776
  isNewProfile;
777
777
  constructor(e) {
778
- super(e), this.type = ae.PROFILE, this.isNewProfile = e.isNewProfile || !1;
778
+ super(e), this.type = he.PROFILE, this.isNewProfile = e.isNewProfile || !1;
779
779
  }
780
- static newInstance = () => new ue({
781
- id: K(),
780
+ static newInstance = () => new be({
781
+ id: X(),
782
782
  isNewProfile: !0
783
783
  });
784
784
  }
785
- class Be {
785
+ class Ve {
786
786
  id;
787
787
  code;
788
788
  version;
@@ -792,25 +792,25 @@ class Be {
792
792
  lastModifiedByUser;
793
793
  group;
794
794
  constructor(e) {
795
- this.id = e.id, this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.updateEntityDate = e.updateEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.group = e.group ? new he(e.group) : void 0;
795
+ this.id = e.id, this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.updateEntityDate = e.updateEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.group = e.group ? new Ae(e.group) : void 0;
796
796
  }
797
- static newInstance = (e) => new Be({
798
- id: K(),
797
+ static newInstance = (e) => new Ve({
798
+ id: X(),
799
799
  group: e
800
800
  });
801
801
  }
802
- class he extends le {
802
+ class Ae extends me {
803
803
  type;
804
804
  isNewGroup;
805
805
  constructor(e) {
806
- super(e), this.type = ae.GROUP, this.isNewGroup = e.isNewGroup || !1;
806
+ super(e), this.type = he.GROUP, this.isNewGroup = e.isNewGroup || !1;
807
807
  }
808
- static newInstance = () => new he({
809
- id: K(),
808
+ static newInstance = () => new Ae({
809
+ id: X(),
810
810
  isNewGroup: !0
811
811
  });
812
812
  }
813
- const be = class ut {
813
+ const De = class At {
814
814
  id;
815
815
  code;
816
816
  version;
@@ -827,28 +827,28 @@ const be = class ut {
827
827
  constructor(e) {
828
828
  this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || "", this.updateEntityDate = e.updateEntityDate || "", this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.name = e.name || "", this.description = e.description || "", this.actions = e.actions || [], this.active = e.active || !1, this.type = e.type || "VIEW", this.isNewResource = e.isNewResource || !1;
829
829
  }
830
- static newInstance = () => new ut({
831
- id: K(),
830
+ static newInstance = () => new At({
831
+ id: X(),
832
832
  actions: [],
833
833
  active: !0,
834
834
  isNewResource: !0
835
835
  });
836
836
  };
837
- v([
838
- J({
837
+ x([
838
+ q({
839
839
  message: "archbase:Informe o nome para o recurso"
840
840
  })
841
- ], be.prototype, "name");
842
- v([
843
- J({
841
+ ], De.prototype, "name");
842
+ x([
843
+ q({
844
844
  message: "archbase:Informe a descrição para o recurso"
845
845
  })
846
- ], be.prototype, "description");
847
- v([
848
- q()
849
- ], be.prototype, "active");
850
- let ht = be;
851
- const M = class pt extends le {
846
+ ], De.prototype, "description");
847
+ x([
848
+ ee()
849
+ ], De.prototype, "active");
850
+ let Et = De;
851
+ const W = class xt extends me {
852
852
  userName;
853
853
  password;
854
854
  changePasswordOnNextLogin;
@@ -868,10 +868,10 @@ const M = class pt extends le {
868
868
  type;
869
869
  isNewUser;
870
870
  constructor(e) {
871
- super(e), this.type = ae.USER, this.userName = e.userName || "", this.password = e.password || "", this.changePasswordOnNextLogin = e.changePasswordOnNextLogin || !1, this.allowPasswordChange = e.allowPasswordChange || !1, this.allowMultipleLogins = e.allowMultipleLogins || !1, this.passwordNeverExpires = e.passwordNeverExpires || !1, this.accountDeactivated = e.accountDeactivated || !1, this.accountLocked = e.accountLocked || !1, this.unlimitedAccessHours = e.unlimitedAccessHours || !1, this.isAdministrator = e.isAdministrator || !1, this.accessSchedule = e.accessSchedule ? new ct(e.accessSchedule) : void 0, this.groups = e.groups ? e.groups.map((t) => new Be(t)) : [], this.profile = e.profile ? new ue(e.profile) : void 0, this.email = e.email || "", this.avatar = e.avatar || void 0, this.isNewUser = e.isNewUser || !1, this.nickname = e.nickname;
871
+ super(e), this.type = he.USER, this.userName = e.userName || "", this.password = e.password || "", this.changePasswordOnNextLogin = e.changePasswordOnNextLogin || !1, this.allowPasswordChange = e.allowPasswordChange || !1, this.allowMultipleLogins = e.allowMultipleLogins || !1, this.passwordNeverExpires = e.passwordNeverExpires || !1, this.accountDeactivated = e.accountDeactivated || !1, this.accountLocked = e.accountLocked || !1, this.unlimitedAccessHours = e.unlimitedAccessHours || !1, this.isAdministrator = e.isAdministrator || !1, this.accessSchedule = e.accessSchedule ? new wt(e.accessSchedule) : void 0, this.groups = e.groups ? e.groups.map((t) => new Ve(t)) : [], this.profile = e.profile ? new be(e.profile) : void 0, this.email = e.email || "", this.avatar = e.avatar || void 0, this.isNewUser = e.isNewUser || !1, this.nickname = e.nickname;
872
872
  }
873
- static newInstance = () => new pt({
874
- id: K(),
873
+ static newInstance = () => new xt({
874
+ id: X(),
875
875
  userName: "",
876
876
  password: "",
877
877
  groups: [],
@@ -882,54 +882,54 @@ const M = class pt extends le {
882
882
  isNewUser: !0
883
883
  });
884
884
  };
885
- v([
886
- J({
885
+ x([
886
+ q({
887
887
  message: "archbase:Informe o nome de usuário"
888
888
  })
889
- ], M.prototype, "userName");
890
- v([
891
- q()
892
- ], M.prototype, "changePasswordOnNextLogin");
893
- v([
894
- q()
895
- ], M.prototype, "allowPasswordChange");
896
- v([
897
- q()
898
- ], M.prototype, "allowMultipleLogins");
899
- v([
900
- q()
901
- ], M.prototype, "passwordNeverExpires");
902
- v([
903
- q()
904
- ], M.prototype, "accountDeactivated");
905
- v([
906
- q()
907
- ], M.prototype, "accountLocked");
908
- v([
909
- q()
910
- ], M.prototype, "unlimitedAccessHours");
911
- v([
912
- q()
913
- ], M.prototype, "isAdministrator");
914
- v([
915
- re()
916
- ], M.prototype, "accessSchedule");
917
- v([
918
- re()
919
- ], M.prototype, "groups");
920
- v([
921
- re()
922
- ], M.prototype, "profile");
923
- v([
924
- Tt(
889
+ ], W.prototype, "userName");
890
+ x([
891
+ ee()
892
+ ], W.prototype, "changePasswordOnNextLogin");
893
+ x([
894
+ ee()
895
+ ], W.prototype, "allowPasswordChange");
896
+ x([
897
+ ee()
898
+ ], W.prototype, "allowMultipleLogins");
899
+ x([
900
+ ee()
901
+ ], W.prototype, "passwordNeverExpires");
902
+ x([
903
+ ee()
904
+ ], W.prototype, "accountDeactivated");
905
+ x([
906
+ ee()
907
+ ], W.prototype, "accountLocked");
908
+ x([
909
+ ee()
910
+ ], W.prototype, "unlimitedAccessHours");
911
+ x([
912
+ ee()
913
+ ], W.prototype, "isAdministrator");
914
+ x([
915
+ ce()
916
+ ], W.prototype, "accessSchedule");
917
+ x([
918
+ ce()
919
+ ], W.prototype, "groups");
920
+ x([
921
+ ce()
922
+ ], W.prototype, "profile");
923
+ x([
924
+ $t(
925
925
  {},
926
926
  {
927
927
  message: "archbase:Informe um email válido"
928
928
  }
929
929
  )
930
- ], M.prototype, "email");
931
- let Ee = M;
932
- const Me = class De {
930
+ ], W.prototype, "email");
931
+ let _e = W;
932
+ const We = class $e {
933
933
  id;
934
934
  code;
935
935
  version;
@@ -943,35 +943,35 @@ const Me = class De {
943
943
  companyId;
944
944
  projectId;
945
945
  constructor(e) {
946
- this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || "", this.updateEntityDate = e.updateEntityDate || "", this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.security = e.security ? De.createDtoFromJson(e.security) : void 0, this.action = e.action ? new ar(e.action) : void 0, this.tenantId = e.tenantId || "", this.companyId = e.companyId || "", this.projectId = e.projectId || "";
946
+ this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || "", this.updateEntityDate = e.updateEntityDate || "", this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.security = e.security ? $e.createDtoFromJson(e.security) : void 0, this.action = e.action ? new wr(e.action) : void 0, this.tenantId = e.tenantId || "", this.companyId = e.companyId || "", this.projectId = e.projectId || "";
947
947
  }
948
948
  static createDtoFromJson(e) {
949
949
  switch (e.type) {
950
950
  case "profile":
951
- return new ue(e);
951
+ return new be(e);
952
952
  case "group":
953
- return new he(e);
953
+ return new Ae(e);
954
954
  case "user":
955
- return new Ee(e);
955
+ return new _e(e);
956
956
  default:
957
957
  throw new Error("Unknown DTO type");
958
958
  }
959
959
  }
960
- static newInstance = () => new De({
961
- id: K(),
960
+ static newInstance = () => new $e({
961
+ id: X(),
962
962
  tenantId: "",
963
963
  companyId: "",
964
964
  projectId: ""
965
965
  });
966
966
  };
967
- v([
968
- re()
969
- ], Me.prototype, "security");
970
- v([
971
- re()
972
- ], Me.prototype, "action");
973
- let _r = Me;
974
- class Oe {
967
+ x([
968
+ ce()
969
+ ], We.prototype, "security");
970
+ x([
971
+ ce()
972
+ ], We.prototype, "action");
973
+ let Fr = We;
974
+ class He {
975
975
  id;
976
976
  code;
977
977
  version;
@@ -989,13 +989,13 @@ class Oe {
989
989
  activated;
990
990
  isNovoToken;
991
991
  constructor(e) {
992
- this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || "", this.updateEntityDate = e.updateEntityDate || "", this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.tenantId = e.tenantId || "", this.user = e.user ? new Ee(e.user) : void 0, this.name = e.name || "", this.description = e.description || "", this.token = e.token || "", this.expirationDate = e.expirationDate, this.revoked = e.revoked, this.activated = e.activated || !1;
992
+ this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || "", this.updateEntityDate = e.updateEntityDate || "", this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.tenantId = e.tenantId || "", this.user = e.user ? new _e(e.user) : void 0, this.name = e.name || "", this.description = e.description || "", this.token = e.token || "", this.expirationDate = e.expirationDate, this.revoked = e.revoked, this.activated = e.activated || !1;
993
993
  }
994
- static newInstance = () => new Oe({
995
- id: K()
994
+ static newInstance = () => new He({
995
+ id: X()
996
996
  });
997
997
  }
998
- class Le {
998
+ class Ge {
999
999
  id;
1000
1000
  code;
1001
1001
  version;
@@ -1012,23 +1012,23 @@ class Le {
1012
1012
  user;
1013
1013
  isNewAccessToken;
1014
1014
  constructor(e) {
1015
- this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.updateEntityDate = e.updateEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.token = e.token || "", this.tokenType = e.tokenType || void 0, this.user = e.user ? new Ee(e.user) : void 0, this.revoked = e.revoked || !1, this.expired = e.expired || !1, this.expirationTime = e.expirationTime || 0, this.expirationDate = e.expirationDate || "", this.isNewAccessToken = e.isNewAccessToken || !1;
1015
+ this.id = e.id || "", this.code = e.code || "", this.version = e.version || 0, this.createEntityDate = e.createEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.updateEntityDate = e.updateEntityDate || (/* @__PURE__ */ new Date()).toISOString(), this.createdByUser = e.createdByUser || "", this.lastModifiedByUser = e.lastModifiedByUser || "", this.token = e.token || "", this.tokenType = e.tokenType || void 0, this.user = e.user ? new _e(e.user) : void 0, this.revoked = e.revoked || !1, this.expired = e.expired || !1, this.expirationTime = e.expirationTime || 0, this.expirationDate = e.expirationDate || "", this.isNewAccessToken = e.isNewAccessToken || !1;
1016
1016
  }
1017
- static newInstance = () => new Le({
1018
- id: K(),
1017
+ static newInstance = () => new Ge({
1018
+ id: X(),
1019
1019
  active: !0,
1020
1020
  isNewAccessToken: !0
1021
1021
  });
1022
1022
  }
1023
- class ft extends ce {
1023
+ class kt extends pe {
1024
1024
  constructor(e) {
1025
1025
  super(e);
1026
1026
  }
1027
1027
  configureHeaders() {
1028
- return V.getInstance().getHeaders();
1028
+ return G.getInstance().getHeaders();
1029
1029
  }
1030
1030
  transform(e) {
1031
- return new Ee(e);
1031
+ return new _e(e);
1032
1032
  }
1033
1033
  getEndpoint() {
1034
1034
  return "/api/v1/user";
@@ -1047,17 +1047,17 @@ class ft extends ce {
1047
1047
  return this.transform(t);
1048
1048
  }
1049
1049
  }
1050
- I.decorate(I.inject(G.ApiClient), ft, 0);
1051
- I.decorate(I.injectable(), ft);
1052
- class mt extends ce {
1050
+ I.decorate(I.inject(Y.ApiClient), kt, 0);
1051
+ I.decorate(I.injectable(), kt);
1052
+ class St extends pe {
1053
1053
  constructor(e) {
1054
1054
  super(e);
1055
1055
  }
1056
1056
  configureHeaders() {
1057
- return V.getInstance().getHeaders();
1057
+ return G.getInstance().getHeaders();
1058
1058
  }
1059
1059
  transform(e) {
1060
- return new he(e);
1060
+ return new Ae(e);
1061
1061
  }
1062
1062
  getEndpoint() {
1063
1063
  return "/api/v1/group";
@@ -1069,17 +1069,17 @@ class mt extends ce {
1069
1069
  return e.isNewGroup;
1070
1070
  }
1071
1071
  }
1072
- I.decorate(I.inject(G.ApiClient), mt, 0);
1073
- I.decorate(I.injectable(), mt);
1074
- class gt extends ce {
1072
+ I.decorate(I.inject(Y.ApiClient), St, 0);
1073
+ I.decorate(I.injectable(), St);
1074
+ class It extends pe {
1075
1075
  constructor(e) {
1076
1076
  super(e);
1077
1077
  }
1078
1078
  configureHeaders() {
1079
- return V.getInstance().getHeaders();
1079
+ return G.getInstance().getHeaders();
1080
1080
  }
1081
1081
  transform(e) {
1082
- return new ue(e);
1082
+ return new be(e);
1083
1083
  }
1084
1084
  getEndpoint() {
1085
1085
  return "/api/v1/userProfile";
@@ -1091,17 +1091,17 @@ class gt extends ce {
1091
1091
  return e.isNewProfile;
1092
1092
  }
1093
1093
  }
1094
- I.decorate(I.inject(G.ApiClient), gt, 0);
1095
- I.decorate(I.injectable(), gt);
1096
- class yt extends ce {
1094
+ I.decorate(I.inject(Y.ApiClient), It, 0);
1095
+ I.decorate(I.injectable(), It);
1096
+ class Ct extends pe {
1097
1097
  constructor(e) {
1098
1098
  super(e);
1099
1099
  }
1100
1100
  configureHeaders() {
1101
- return V.getInstance().getHeaders();
1101
+ return G.getInstance().getHeaders();
1102
1102
  }
1103
1103
  transform(e) {
1104
- return new Oe(e);
1104
+ return new He(e);
1105
1105
  }
1106
1106
  getEndpoint() {
1107
1107
  return "/api/v1/apiToken";
@@ -1128,17 +1128,17 @@ class yt extends ce {
1128
1128
  );
1129
1129
  }
1130
1130
  }
1131
- I.decorate(I.inject(G.ApiClient), yt, 0);
1132
- I.decorate(I.injectable(), yt);
1133
- class wt extends ce {
1131
+ I.decorate(I.inject(Y.ApiClient), Ct, 0);
1132
+ I.decorate(I.injectable(), Ct);
1133
+ class Pt extends pe {
1134
1134
  constructor(e) {
1135
1135
  super(e);
1136
1136
  }
1137
1137
  configureHeaders() {
1138
- return V.getInstance().getHeaders();
1138
+ return G.getInstance().getHeaders();
1139
1139
  }
1140
1140
  transform(e) {
1141
- return new Le(e);
1141
+ return new Ge(e);
1142
1142
  }
1143
1143
  getEndpoint() {
1144
1144
  return "/api/v1/accessToken";
@@ -1157,17 +1157,17 @@ class wt extends ce {
1157
1157
  );
1158
1158
  }
1159
1159
  }
1160
- I.decorate(I.inject(G.ApiClient), wt, 0);
1161
- I.decorate(I.injectable(), wt);
1162
- class vt extends ce {
1160
+ I.decorate(I.inject(Y.ApiClient), Pt, 0);
1161
+ I.decorate(I.injectable(), Pt);
1162
+ class Tt extends pe {
1163
1163
  constructor(e) {
1164
1164
  super(e);
1165
1165
  }
1166
1166
  configureHeaders() {
1167
- return V.getInstance().getHeaders();
1167
+ return G.getInstance().getHeaders();
1168
1168
  }
1169
1169
  transform(e) {
1170
- return new ht(e);
1170
+ return new Et(e);
1171
1171
  }
1172
1172
  getEndpoint() {
1173
1173
  return "/api/v1/resource";
@@ -1191,7 +1191,7 @@ class vt extends ce {
1191
1191
  !1,
1192
1192
  {
1193
1193
  params: {
1194
- type: Ve(ae, t)
1194
+ type: Ye(he, t)
1195
1195
  }
1196
1196
  }
1197
1197
  );
@@ -1202,7 +1202,7 @@ class vt extends ce {
1202
1202
  {
1203
1203
  securityId: e,
1204
1204
  actionId: t,
1205
- type: Ve(ae, s)
1205
+ type: Ye(he, s)
1206
1206
  },
1207
1207
  this.configureHeaders()
1208
1208
  );
@@ -1221,9 +1221,9 @@ class vt extends ce {
1221
1221
  );
1222
1222
  }
1223
1223
  }
1224
- I.decorate(I.inject(G.ApiClient), vt, 0);
1225
- I.decorate(I.injectable(), vt);
1226
- function Dr({
1224
+ I.decorate(I.inject(Y.ApiClient), Tt, 0);
1225
+ I.decorate(I.injectable(), Tt);
1226
+ function Vr({
1227
1227
  onLogin: r,
1228
1228
  error: e,
1229
1229
  onClickForgotPassword: t,
@@ -1231,527 +1231,682 @@ function Dr({
1231
1231
  loginPlaceholder: o,
1232
1232
  afterInputs: c,
1233
1233
  showMockUsersSelector: l = !1,
1234
- mockUsers: i = [],
1235
- mockUsersGroupMap: u,
1236
- options: m = {},
1234
+ mockUsers: a = [],
1235
+ mockUsersGroupMap: d,
1236
+ options: y = {},
1237
1237
  onChangeUsername: b,
1238
- disabledLogin: h = !1,
1238
+ disabledLogin: u = !1,
1239
1239
  isCheckingUsername: C = !1,
1240
- showSignIn: E = !0
1240
+ showSignIn: v = !0,
1241
+ mfaRequired: g = !1,
1242
+ onVerifyMfa: S,
1243
+ mfaError: P,
1244
+ onCancelMfa: B,
1245
+ isVerifyingMfa: R = !1
1241
1246
  }) {
1242
- const y = Qe(), {
1243
- username: x,
1244
- password: U,
1245
- rememberMe: _,
1246
- clearRememberMe: O
1247
- } = Ct(), [D, N] = f(x), [k, A] = f(U), [P, W] = f(_), [L, B] = f(!1), [H, Y] = f(null);
1248
- z(() => {
1249
- B(!!e);
1250
- }, [e]), z(() => {
1251
- x !== D && (N(x), b?.(x)), U !== k && A(U), _ !== P && W(_);
1252
- }, [x, U, _]);
1253
- const $ = () => {
1254
- B(!1);
1255
- }, X = () => {
1256
- D && k && r(D, k, P).finally(() => B(!0));
1257
- }, p = () => {
1258
- if (!u)
1259
- return i.map((g) => ({
1260
- value: g.email,
1261
- label: g.email
1247
+ const z = ct(), {
1248
+ username: U,
1249
+ password: h,
1250
+ rememberMe: w,
1251
+ clearRememberMe: D
1252
+ } = zt(), [j, F] = m(U), [N, Q] = m(h), [Z, K] = m(w), [se, f] = m(!1), [i, E] = m(null), [p, _] = m("");
1253
+ J(() => {
1254
+ f(!!e);
1255
+ }, [e]), J(() => {
1256
+ U !== j && (F(U), b?.(U)), h !== N && Q(h), w !== Z && K(w);
1257
+ }, [U, h, w]);
1258
+ const M = () => {
1259
+ f(!1);
1260
+ }, te = () => {
1261
+ j && N && r(j, N, Z).finally(() => f(!0));
1262
+ }, le = () => {
1263
+ const T = p.trim();
1264
+ T && S && S(T);
1265
+ }, ge = () => {
1266
+ if (!d)
1267
+ return a.map((L) => ({
1268
+ value: L.email,
1269
+ label: L.email
1262
1270
  }));
1263
- const a = i.reduce((g, T) => {
1264
- const j = u[T.type];
1265
- return j && (g[j] || (g[j] = []), g[j].push({
1266
- value: T.email,
1267
- label: T.email
1268
- })), g;
1271
+ const T = a.reduce((L, ye) => {
1272
+ const xe = d[ye.type];
1273
+ return xe && (L[xe] || (L[xe] = []), L[xe].push({
1274
+ value: ye.email,
1275
+ label: ye.email
1276
+ })), L;
1269
1277
  }, {});
1270
- return Object.entries(a).map(([g, T]) => ({
1271
- group: g,
1272
- items: T
1278
+ return Object.entries(T).map(([L, ye]) => ({
1279
+ group: L,
1280
+ items: ye
1273
1281
  }));
1274
- }, n = () => {
1275
- if (H) {
1276
- const a = i.find((g) => g.email === H);
1277
- a && (N(a.email), A(a.password), $());
1282
+ }, Ee = () => {
1283
+ if (i) {
1284
+ const T = a.find((L) => L.email === i);
1285
+ T && (F(T.email), Q(T.password), M());
1278
1286
  }
1279
- }, w = {
1287
+ }, Rt = {
1280
1288
  withBorder: !0,
1281
1289
  shadow: "md",
1282
1290
  p: 30,
1283
1291
  mt: 30,
1284
1292
  radius: "md",
1285
1293
  w: 400,
1286
- ...m.cardProps
1294
+ ...y.cardProps
1287
1295
  };
1288
- return /* @__PURE__ */ R(
1289
- Ye,
1296
+ return /* @__PURE__ */ k(
1297
+ Fe,
1290
1298
  {
1291
- ...w,
1299
+ ...Rt,
1292
1300
  pos: "relative",
1293
- ref: y,
1301
+ ref: z,
1294
1302
  children: [
1295
- E && /* @__PURE__ */ R(te, { children: [
1296
- /* @__PURE__ */ d(
1297
- se,
1303
+ v && /* @__PURE__ */ k(re, { children: [
1304
+ /* @__PURE__ */ n(
1305
+ $,
1298
1306
  {
1299
1307
  c: "light-dark(var(--mantine-color-black), var(--mantine-color-white))",
1300
1308
  fw: 800,
1301
1309
  fz: { base: "20px", md: "35px" },
1302
1310
  style: { textAlign: "center", letterSpacing: "-1px" },
1303
1311
  mt: "xs",
1304
- children: S().t("archbase:signIn")
1312
+ children: A().t("archbase:signIn")
1305
1313
  }
1306
1314
  ),
1307
- /* @__PURE__ */ d(ye, { m: "md" })
1315
+ /* @__PURE__ */ n(Pe, { m: "md" })
1308
1316
  ] }),
1309
- m?.customContentBefore,
1310
- l && /* @__PURE__ */ R(te, { children: [
1311
- /* @__PURE__ */ R(we, { gap: "sm", mb: "md", children: [
1312
- /* @__PURE__ */ d(
1313
- Nt,
1314
- {
1315
- placeholder: "Selecione um usuário mock",
1316
- data: p(),
1317
- value: H,
1318
- onChange: (a) => Y(a ?? ""),
1319
- searchable: !0,
1320
- clearable: !0,
1321
- style: { flexGrow: 1 }
1322
- }
1323
- ),
1324
- /* @__PURE__ */ d(Bt, { label: "Aplicar", children: /* @__PURE__ */ d(
1325
- ie,
1326
- {
1327
- variant: "light",
1328
- size: "sm",
1329
- onClick: n,
1330
- disabled: !H,
1331
- "aria-label": "Aplicar usuário mock selecionado",
1332
- children: /* @__PURE__ */ d(Ft, { size: 16 })
1333
- }
1317
+ y?.customContentBefore,
1318
+ g && /* @__PURE__ */ k(we, { gap: "md", children: [
1319
+ /* @__PURE__ */ k("div", { children: [
1320
+ /* @__PURE__ */ n($, { fw: 700, fz: "lg", children: A().t("archbase:mfa.title", "Verificação em duas etapas") }),
1321
+ /* @__PURE__ */ n($, { c: "dimmed", fz: "sm", children: A().t(
1322
+ "archbase:mfa.subtitle",
1323
+ "Digite o código do seu aplicativo autenticador (ou um código de recuperação)."
1334
1324
  ) })
1335
1325
  ] }),
1336
- /* @__PURE__ */ d(ye, { mb: "md" })
1337
- ] }),
1338
- /* @__PURE__ */ d(
1339
- Ce,
1340
- {
1341
- label: s,
1342
- placeholder: o ?? S().t("archbase:usuario@email.com"),
1343
- rightSection: C ? /* @__PURE__ */ d(Xe, { size: "xs" }) : null,
1344
- value: D || "",
1345
- required: !0,
1346
- onChange: (a) => {
1347
- N(a.currentTarget.value), b?.(a.currentTarget.value), $();
1348
- }
1349
- }
1350
- ),
1351
- /* @__PURE__ */ d(
1352
- Ue,
1353
- {
1354
- label: S().t("archbase:Password"),
1355
- placeholder: S().t("archbase:Sua senha"),
1356
- onChange: (a) => {
1357
- A(a.currentTarget.value), $();
1358
- },
1359
- value: k || "",
1360
- required: !0,
1361
- mt: "md"
1362
- }
1363
- ),
1364
- /* @__PURE__ */ R(we, { justify: "space-between", mt: "md", children: [
1365
- /* @__PURE__ */ d(
1366
- Mt,
1326
+ /* @__PURE__ */ n(
1327
+ ve,
1367
1328
  {
1368
- label: S().t("archbase:Lembre-me"),
1369
- checked: P,
1370
- onChange: (a) => {
1371
- const g = a.currentTarget.checked;
1372
- W(g), g || O();
1329
+ label: A().t("archbase:mfa.code", "Código de verificação"),
1330
+ placeholder: "000000",
1331
+ value: p,
1332
+ autoFocus: !0,
1333
+ onChange: (T) => _(T.currentTarget.value),
1334
+ onKeyDown: (T) => {
1335
+ T.key === "Enter" && le();
1373
1336
  }
1374
1337
  }
1375
1338
  ),
1376
- t && /* @__PURE__ */ d(
1377
- Ot,
1339
+ P && /* @__PURE__ */ n($, { c: "red", fz: "sm", children: P }),
1340
+ /* @__PURE__ */ n(
1341
+ V,
1342
+ {
1343
+ fullWidth: !0,
1344
+ disabled: !p.trim() || R,
1345
+ loading: R,
1346
+ onClick: le,
1347
+ children: A().t("archbase:mfa.verify", "Verificar")
1348
+ }
1349
+ ),
1350
+ B && /* @__PURE__ */ n(
1351
+ Xe,
1378
1352
  {
1379
1353
  component: "button",
1380
1354
  c: "var(--mantine-text-color)",
1381
1355
  fz: 14,
1382
- lh: "20px",
1356
+ ta: "center",
1383
1357
  styles: { root: { cursor: "pointer" } },
1384
- onClick: t,
1385
- children: S().t("archbase:Esqueci minha senha")
1358
+ onClick: B,
1359
+ children: A().t("archbase:mfa.back", "Voltar ao login")
1386
1360
  }
1387
1361
  )
1388
1362
  ] }),
1389
- m?.afterInputs || c,
1390
- /* @__PURE__ */ d(
1391
- ie,
1392
- {
1393
- disabled: !k || !D || h,
1394
- fullWidth: !0,
1395
- mt: "xl",
1396
- onClick: X,
1397
- children: S().t("archbase:signIn")
1398
- }
1399
- ),
1400
- m?.customContentAfter,
1401
- L && e && /* @__PURE__ */ d(se, { c: "red", mt: "sm", children: e })
1363
+ !g && /* @__PURE__ */ k(re, { children: [
1364
+ l && /* @__PURE__ */ k(re, { children: [
1365
+ /* @__PURE__ */ k(ae, { gap: "sm", mb: "md", children: [
1366
+ /* @__PURE__ */ n(
1367
+ Ht,
1368
+ {
1369
+ placeholder: "Selecione um usuário mock",
1370
+ data: ge(),
1371
+ value: i,
1372
+ onChange: (T) => E(T ?? ""),
1373
+ searchable: !0,
1374
+ clearable: !0,
1375
+ style: { flexGrow: 1 }
1376
+ }
1377
+ ),
1378
+ /* @__PURE__ */ n(Gt, { label: "Aplicar", children: /* @__PURE__ */ n(
1379
+ V,
1380
+ {
1381
+ variant: "light",
1382
+ size: "sm",
1383
+ onClick: Ee,
1384
+ disabled: !i,
1385
+ "aria-label": "Aplicar usuário mock selecionado",
1386
+ children: /* @__PURE__ */ n(Xt, { size: 16 })
1387
+ }
1388
+ ) })
1389
+ ] }),
1390
+ /* @__PURE__ */ n(Pe, { mb: "md" })
1391
+ ] }),
1392
+ /* @__PURE__ */ n(
1393
+ ve,
1394
+ {
1395
+ label: s,
1396
+ placeholder: o ?? A().t("archbase:usuario@email.com"),
1397
+ rightSection: C ? /* @__PURE__ */ n(at, { size: "xs" }) : null,
1398
+ value: j || "",
1399
+ required: !0,
1400
+ onChange: (T) => {
1401
+ F(T.currentTarget.value), b?.(T.currentTarget.value), M();
1402
+ }
1403
+ }
1404
+ ),
1405
+ /* @__PURE__ */ n(
1406
+ Oe,
1407
+ {
1408
+ label: A().t("archbase:Password"),
1409
+ placeholder: A().t("archbase:Sua senha"),
1410
+ onChange: (T) => {
1411
+ Q(T.currentTarget.value), M();
1412
+ },
1413
+ value: N || "",
1414
+ required: !0,
1415
+ mt: "md"
1416
+ }
1417
+ ),
1418
+ /* @__PURE__ */ k(ae, { justify: "space-between", mt: "md", children: [
1419
+ /* @__PURE__ */ n(
1420
+ Jt,
1421
+ {
1422
+ label: A().t("archbase:Lembre-me"),
1423
+ checked: Z,
1424
+ onChange: (T) => {
1425
+ const L = T.currentTarget.checked;
1426
+ K(L), L || D();
1427
+ }
1428
+ }
1429
+ ),
1430
+ t && /* @__PURE__ */ n(
1431
+ Xe,
1432
+ {
1433
+ component: "button",
1434
+ c: "var(--mantine-text-color)",
1435
+ fz: 14,
1436
+ lh: "20px",
1437
+ styles: { root: { cursor: "pointer" } },
1438
+ onClick: t,
1439
+ children: A().t("archbase:Esqueci minha senha")
1440
+ }
1441
+ )
1442
+ ] }),
1443
+ y?.afterInputs || c,
1444
+ /* @__PURE__ */ n(
1445
+ V,
1446
+ {
1447
+ disabled: !N || !j || u,
1448
+ fullWidth: !0,
1449
+ mt: "xl",
1450
+ onClick: te,
1451
+ children: A().t("archbase:signIn")
1452
+ }
1453
+ )
1454
+ ] }),
1455
+ y?.customContentAfter,
1456
+ se && e && /* @__PURE__ */ n($, { c: "red", mt: "sm", children: e })
1402
1457
  ]
1403
1458
  }
1404
1459
  );
1405
1460
  }
1406
- const cr = {
1461
+ const O = (r, e) => A().t(r, e);
1462
+ function Wr({
1463
+ enabled: r,
1464
+ onSetup: e,
1465
+ onEnable: t,
1466
+ onDisable: s,
1467
+ onStatusChange: o
1468
+ }) {
1469
+ const [c, l] = m("idle"), [a, d] = m(null), [y, b] = m(""), [u, C] = m([]), [v, g] = m(!1), [S, P] = m(null), B = async () => {
1470
+ g(!0), P(null);
1471
+ try {
1472
+ const h = await e();
1473
+ d(h), b(""), l("setup");
1474
+ } catch (h) {
1475
+ P(h?.message || String(h));
1476
+ } finally {
1477
+ g(!1);
1478
+ }
1479
+ }, R = async () => {
1480
+ const h = y.trim();
1481
+ if (h) {
1482
+ g(!0), P(null);
1483
+ try {
1484
+ const w = await t(h);
1485
+ C(w), l("recovery"), o?.(!0);
1486
+ } catch (w) {
1487
+ P(w?.message || String(w));
1488
+ } finally {
1489
+ g(!1);
1490
+ }
1491
+ }
1492
+ }, z = async () => {
1493
+ g(!0), P(null);
1494
+ try {
1495
+ await s(), d(null), C([]), l("idle"), o?.(!1);
1496
+ } catch (h) {
1497
+ P(h?.message || String(h));
1498
+ } finally {
1499
+ g(!1);
1500
+ }
1501
+ }, U = () => {
1502
+ C([]), d(null), b(""), l("idle");
1503
+ };
1504
+ return /* @__PURE__ */ n(Fe, { withBorder: !0, radius: "md", p: "lg", children: /* @__PURE__ */ k(we, { gap: "md", children: [
1505
+ /* @__PURE__ */ k("div", { children: [
1506
+ /* @__PURE__ */ n($, { fw: 700, fz: "lg", children: O("archbase:mfa.setup.title", "Autenticação em duas etapas (MFA)") }),
1507
+ /* @__PURE__ */ n($, { c: "dimmed", fz: "sm", children: O(
1508
+ "archbase:mfa.setup.subtitle",
1509
+ "Proteja o acesso exigindo um código do seu aplicativo autenticador no login."
1510
+ ) })
1511
+ ] }),
1512
+ S && /* @__PURE__ */ n(Qe, { color: "red", children: S }),
1513
+ r && c === "idle" && /* @__PURE__ */ k(ae, { justify: "space-between", children: [
1514
+ /* @__PURE__ */ n($, { c: "teal", fw: 600, children: O("archbase:mfa.setup.active", "MFA ativo") }),
1515
+ /* @__PURE__ */ n(V, { color: "red", variant: "light", loading: v, onClick: z, children: O("archbase:mfa.setup.disable", "Desativar") })
1516
+ ] }),
1517
+ !r && c === "idle" && /* @__PURE__ */ n(V, { loading: v, onClick: B, children: O("archbase:mfa.setup.enable", "Ativar MFA") }),
1518
+ c === "setup" && a && /* @__PURE__ */ k(we, { gap: "sm", align: "center", children: [
1519
+ /* @__PURE__ */ n($, { fz: "sm", ta: "center", children: O(
1520
+ "archbase:mfa.setup.scan",
1521
+ "Escaneie o QR Code no seu app autenticador (Google Authenticator, Authy…):"
1522
+ ) }),
1523
+ /* @__PURE__ */ n(Qt, { value: a.provisioningUri, size: 180, level: "M" }),
1524
+ /* @__PURE__ */ n($, { fz: "xs", c: "dimmed", ta: "center", children: O("archbase:mfa.setup.manual", "Ou informe o código manualmente:") }),
1525
+ /* @__PURE__ */ k(ae, { gap: "xs", children: [
1526
+ /* @__PURE__ */ n(Ze, { children: a.secret }),
1527
+ /* @__PURE__ */ n(et, { value: a.secret, children: ({ copied: h, copy: w }) => /* @__PURE__ */ n(V, { size: "xs", variant: "subtle", onClick: w, children: h ? O("archbase:mfa.setup.copied", "Copiado") : O("archbase:mfa.setup.copy", "Copiar") }) })
1528
+ ] }),
1529
+ /* @__PURE__ */ n(
1530
+ ve,
1531
+ {
1532
+ w: "100%",
1533
+ label: O("archbase:mfa.setup.confirmCode", "Digite o código gerado para confirmar"),
1534
+ placeholder: "000000",
1535
+ value: y,
1536
+ onChange: (h) => b(h.currentTarget.value),
1537
+ onKeyDown: (h) => {
1538
+ h.key === "Enter" && R();
1539
+ }
1540
+ }
1541
+ ),
1542
+ /* @__PURE__ */ k(ae, { w: "100%", justify: "flex-end", children: [
1543
+ /* @__PURE__ */ n(V, { variant: "default", onClick: U, disabled: v, children: O("archbase:mfa.setup.cancel", "Cancelar") }),
1544
+ /* @__PURE__ */ n(V, { onClick: R, loading: v, disabled: !y.trim(), children: O("archbase:mfa.setup.confirm", "Confirmar e ativar") })
1545
+ ] })
1546
+ ] }),
1547
+ c === "recovery" && /* @__PURE__ */ k(we, { gap: "sm", children: [
1548
+ /* @__PURE__ */ n(Qe, { color: "yellow", children: O(
1549
+ "archbase:mfa.setup.recoveryWarning",
1550
+ "Guarde estes códigos de recuperação em local seguro. Cada um funciona uma única vez e permite entrar se você perder o acesso ao app autenticador. Eles não serão exibidos novamente."
1551
+ ) }),
1552
+ /* @__PURE__ */ n(Kt, { cols: 2, spacing: "xs", children: u.map((h) => /* @__PURE__ */ n(Ze, { fz: "sm", children: h }, h)) }),
1553
+ /* @__PURE__ */ k(ae, { justify: "space-between", children: [
1554
+ /* @__PURE__ */ n(et, { value: u.join(`
1555
+ `), children: ({ copied: h, copy: w }) => /* @__PURE__ */ n(V, { variant: "subtle", onClick: w, children: h ? O("archbase:mfa.setup.copied", "Copiado") : O("archbase:mfa.setup.copyAll", "Copiar todos") }) }),
1556
+ /* @__PURE__ */ n(V, { onClick: U, children: O("archbase:mfa.setup.done", "Guardei os códigos") })
1557
+ ] })
1558
+ ] })
1559
+ ] }) });
1560
+ }
1561
+ const vr = {
1407
1562
  position: "relative",
1408
1563
  width: "90%",
1409
1564
  maxWidth: 400,
1410
1565
  padding: 30,
1411
1566
  marginTop: 30
1412
1567
  };
1413
- function Rr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClickBackToLogin: s, validatePassword: o, validateToken: c, initialEmail: l = "", description: i, style: u }) {
1414
- const m = Qe(), b = Ut(), { colorScheme: h } = Lt(), [C, E] = f(r ?? ""), [y, x] = f(l), [U, _] = f(""), [O, D] = f(""), [N, k] = f(""), [A, P] = f(!1), [W, L] = f(""), [B, H] = f(""), [Y, $] = f(""), [X, p] = f("");
1415
- async function n(a) {
1416
- a && (_t(a) ? await e(a).then(() => {
1417
- We.showSuccess(`${S().t("archbase:Um e-mail com instruções para redefinir sua senha foi enviado. Verifique sua caixa de entrada.")}`), P(!0);
1568
+ function Hr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClickBackToLogin: s, validatePassword: o, validateToken: c, initialEmail: l = "", description: a, style: d }) {
1569
+ const y = ct(), b = jt(), { colorScheme: u } = Yt(), [C, v] = m(r ?? ""), [g, S] = m(l), [P, B] = m(""), [R, z] = m(""), [U, h] = m(""), [w, D] = m(!1), [j, F] = m(""), [N, Q] = m(""), [Z, K] = m(""), [se, f] = m("");
1570
+ async function i(p) {
1571
+ p && (Ft(p) ? await e(p).then(() => {
1572
+ tt.showSuccess(`${A().t("archbase:Um e-mail com instruções para redefinir sua senha foi enviado. Verifique sua caixa de entrada.")}`), D(!0);
1418
1573
  }).catch(() => {
1419
- }) : L(`${S().t("archbase:Email inválido")}`));
1574
+ }) : F(`${A().t("archbase:Email inválido")}`));
1420
1575
  }
1421
- async function w(a, g, T, j) {
1422
- if (a && g && T) {
1423
- let xe = "", ke = "", Fe = "";
1424
- c && (xe = c(), $(xe)), o && (ke = o(), $(ke)), T !== j && (Fe = `${S().t("archbase:A nova senha e a confirmação devem ser iguais.")}`, p(Fe)), !ke && !xe && await t(a, g, T).then(() => {
1425
- We.showSuccess(`${S().t("archbase:Senha redefinida com sucesso.")}`), s(), P(!1);
1576
+ async function E(p, _, M, te) {
1577
+ if (p && _ && M) {
1578
+ let le = "", ge = "", Ee = "";
1579
+ c && (le = c(), K(le)), o && (ge = o(), K(ge)), M !== te && (Ee = `${A().t("archbase:A nova senha e a confirmação devem ser iguais.")}`, f(Ee)), !ge && !le && await t(p, _, M).then(() => {
1580
+ tt.showSuccess(`${A().t("archbase:Senha redefinida com sucesso.")}`), s(), D(!1);
1426
1581
  }).catch(() => {
1427
- E(r || `${S().t("archbase:Erro ao redefinir senha.")}`);
1582
+ v(r || `${A().t("archbase:Erro ao redefinir senha.")}`);
1428
1583
  });
1429
1584
  }
1430
1585
  }
1431
- return z(() => {
1432
- r && E(r);
1433
- }, [r]), z(() => {
1434
- E("");
1435
- }, [y, U, O, N]), /* @__PURE__ */ R(
1436
- Ye,
1586
+ return J(() => {
1587
+ r && v(r);
1588
+ }, [r]), J(() => {
1589
+ v("");
1590
+ }, [g, P, R, U]), /* @__PURE__ */ k(
1591
+ Fe,
1437
1592
  {
1438
1593
  withBorder: !0,
1439
1594
  shadow: "md",
1440
1595
  radius: "md",
1441
- ref: m,
1596
+ ref: y,
1442
1597
  style: {
1443
- ...cr,
1444
- ...u
1598
+ ...vr,
1599
+ ...d
1445
1600
  },
1446
1601
  children: [
1447
- A ? /* @__PURE__ */ R(te, { children: [
1448
- /* @__PURE__ */ d(
1449
- se,
1602
+ w ? /* @__PURE__ */ k(re, { children: [
1603
+ /* @__PURE__ */ n(
1604
+ $,
1450
1605
  {
1451
1606
  c: "light-dark(var(--mantine-color-black), var(--mantine-color-white))",
1452
1607
  fw: 800,
1453
1608
  fz: { base: "20px", md: "35px" },
1454
1609
  style: { textAlign: "center", letterSpacing: "-1px" },
1455
1610
  mt: "xs",
1456
- children: S().t("archbase:Redefinir senha")
1611
+ children: A().t("archbase:Redefinir senha")
1457
1612
  }
1458
1613
  ),
1459
- /* @__PURE__ */ d(ye, { m: "xs" }),
1460
- /* @__PURE__ */ d(
1461
- Ce,
1614
+ /* @__PURE__ */ n(Pe, { m: "xs" }),
1615
+ /* @__PURE__ */ n(
1616
+ ve,
1462
1617
  {
1463
- label: S().t("archbase:Código de segurança"),
1464
- placeholder: `${S().t("archbase:Código enviado no seu e-mail")}`,
1465
- value: U || "",
1618
+ label: A().t("archbase:Código de segurança"),
1619
+ placeholder: `${A().t("archbase:Código enviado no seu e-mail")}`,
1620
+ value: P || "",
1466
1621
  required: !0,
1467
- onChange: (a) => {
1468
- _(a.currentTarget.value), H("");
1622
+ onChange: (p) => {
1623
+ B(p.currentTarget.value), Q("");
1469
1624
  },
1470
- error: B
1625
+ error: N
1471
1626
  }
1472
1627
  ),
1473
- /* @__PURE__ */ d(
1474
- Ue,
1628
+ /* @__PURE__ */ n(
1629
+ Oe,
1475
1630
  {
1476
- label: S().t("archbase:Nova senha"),
1477
- placeholder: S().t("archbase:Nova senha"),
1478
- onChange: (a) => {
1479
- D(a.currentTarget.value), $(""), p("");
1631
+ label: A().t("archbase:Nova senha"),
1632
+ placeholder: A().t("archbase:Nova senha"),
1633
+ onChange: (p) => {
1634
+ z(p.currentTarget.value), K(""), f("");
1480
1635
  },
1481
- value: O,
1636
+ value: R,
1482
1637
  required: !0,
1483
- error: Y
1638
+ error: Z
1484
1639
  }
1485
1640
  ),
1486
- /* @__PURE__ */ d(
1487
- Ue,
1641
+ /* @__PURE__ */ n(
1642
+ Oe,
1488
1643
  {
1489
- label: S().t("archbase:Confirmar senha"),
1490
- placeholder: S().t("archbase:Confirmar senha"),
1491
- onChange: (a) => {
1492
- k(a.currentTarget.value), p("");
1644
+ label: A().t("archbase:Confirmar senha"),
1645
+ placeholder: A().t("archbase:Confirmar senha"),
1646
+ onChange: (p) => {
1647
+ h(p.currentTarget.value), f("");
1493
1648
  },
1494
- value: N || "",
1649
+ value: U || "",
1495
1650
  required: !0,
1496
- error: X
1651
+ error: se
1497
1652
  }
1498
1653
  ),
1499
- /* @__PURE__ */ d(
1500
- ie,
1654
+ /* @__PURE__ */ n(
1655
+ V,
1501
1656
  {
1502
- disabled: !y || !U || !O || !N,
1657
+ disabled: !g || !P || !R || !U,
1503
1658
  mt: "md",
1504
1659
  fullWidth: !0,
1505
- onClick: () => w(y, U, O, N),
1506
- children: `${S().t("archbase:Redefinir senha")}`
1660
+ onClick: () => E(g, P, R, U),
1661
+ children: `${A().t("archbase:Redefinir senha")}`
1507
1662
  }
1508
1663
  ),
1509
- /* @__PURE__ */ d(
1510
- ie,
1664
+ /* @__PURE__ */ n(
1665
+ V,
1511
1666
  {
1512
1667
  mt: "6px",
1513
1668
  fullWidth: !0,
1514
- color: h === "dark" ? b.colors.dark[4] : b.colors.gray[7],
1669
+ color: u === "dark" ? b.colors.dark[4] : b.colors.gray[7],
1515
1670
  onClick: () => {
1516
- W || P(!1);
1671
+ j || D(!1);
1517
1672
  },
1518
- children: `${S().t("archbase:Voltar")}`
1673
+ children: `${A().t("archbase:Voltar")}`
1519
1674
  }
1520
1675
  )
1521
- ] }) : /* @__PURE__ */ R(te, { children: [
1522
- /* @__PURE__ */ d(
1523
- se,
1676
+ ] }) : /* @__PURE__ */ k(re, { children: [
1677
+ /* @__PURE__ */ n(
1678
+ $,
1524
1679
  {
1525
1680
  c: "light-dark(var(--mantine-color-black), var(--mantine-color-white))",
1526
1681
  fw: 800,
1527
1682
  fz: { base: "20px", md: "35px" },
1528
1683
  style: { textAlign: "center", letterSpacing: "-1px" },
1529
1684
  mt: "xs",
1530
- children: S().t("archbase:Redefinir senha")
1685
+ children: A().t("archbase:Redefinir senha")
1531
1686
  }
1532
1687
  ),
1533
- /* @__PURE__ */ d(se, { c: "dimmed", fz: 14, style: { textAlign: "justify" }, children: i }),
1534
- /* @__PURE__ */ d(ye, { m: "md" }),
1535
- /* @__PURE__ */ d(
1536
- Ce,
1688
+ /* @__PURE__ */ n($, { c: "dimmed", fz: 14, style: { textAlign: "justify" }, children: a }),
1689
+ /* @__PURE__ */ n(Pe, { m: "md" }),
1690
+ /* @__PURE__ */ n(
1691
+ ve,
1537
1692
  {
1538
1693
  label: "Email",
1539
- placeholder: `${S().t("archbase:usuario@email.com")}`,
1540
- value: y || "",
1694
+ placeholder: `${A().t("archbase:usuario@email.com")}`,
1695
+ value: g || "",
1541
1696
  required: !0,
1542
- onChange: (a) => {
1543
- x(a.currentTarget.value), L("");
1697
+ onChange: (p) => {
1698
+ S(p.currentTarget.value), F("");
1544
1699
  },
1545
- error: W
1700
+ error: j
1546
1701
  }
1547
1702
  ),
1548
- /* @__PURE__ */ d(
1549
- ie,
1703
+ /* @__PURE__ */ n(
1704
+ V,
1550
1705
  {
1551
- disabled: !y,
1706
+ disabled: !g,
1552
1707
  mt: "md",
1553
1708
  fullWidth: !0,
1554
- onClick: () => n(y),
1555
- children: `${S().t("archbase:Enviar")}`
1709
+ onClick: () => i(g),
1710
+ children: `${A().t("archbase:Enviar")}`
1556
1711
  }
1557
1712
  ),
1558
- /* @__PURE__ */ d(
1559
- ie,
1713
+ /* @__PURE__ */ n(
1714
+ V,
1560
1715
  {
1561
1716
  mt: "6px",
1562
1717
  fullWidth: !0,
1563
- color: h === "dark" ? b.colors.dark[4] : b.colors.gray[7],
1718
+ color: u === "dark" ? b.colors.dark[4] : b.colors.gray[7],
1564
1719
  onClick: () => s && s(),
1565
- children: `${S().t("archbase:Voltar")}`
1720
+ children: `${A().t("archbase:Voltar")}`
1566
1721
  }
1567
1722
  )
1568
1723
  ] }),
1569
- C ? /* @__PURE__ */ d(se, { c: "red", style: { textAlign: "justify" }, children: C }) : null
1724
+ C ? /* @__PURE__ */ n($, { c: "red", style: { textAlign: "justify" }, children: C }) : null
1570
1725
  ]
1571
1726
  }
1572
1727
  );
1573
1728
  }
1574
- const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourceName: r, resourceDescription: e, enableSecurity: t = !0 }) => {
1575
- const s = qe(At), o = lr(), c = o?.isAdmin ?? !1, l = o?.id, i = Ke(l), u = Je(() => {
1729
+ const br = () => Vt().user, Ut = "archbaseSecurityManagerStore", Gr = ({ resourceName: r, resourceDescription: e, enableSecurity: t = !0 }) => {
1730
+ const s = it(Ut), o = br(), c = o?.isAdmin ?? !1, l = o?.id, a = nt(l), d = ot(() => {
1576
1731
  if (!t)
1577
1732
  return null;
1578
- const m = l ? `${r}_${l}` : r;
1579
- if (s && s.existsValue(m)) {
1580
- const h = s.getValue(m);
1581
- if (h && h.isAdmin === c)
1582
- return h;
1733
+ const y = l ? `${r}_${l}` : r;
1734
+ if (s && s.existsValue(y)) {
1735
+ const u = s.getValue(y);
1736
+ if (u && u.isAdmin === c)
1737
+ return u;
1583
1738
  }
1584
- const b = new nt(r, e, c);
1585
- return s && l && s.setValue(m, b), b;
1739
+ const b = new ft(r, e, c);
1740
+ return s && l && s.setValue(y, b), b;
1586
1741
  }, [t, r, e, c, l]);
1587
- return z(() => {
1588
- i.current = l;
1589
- }, [l]), { securityManager: u };
1590
- }, Br = ({
1742
+ return J(() => {
1743
+ a.current = l;
1744
+ }, [l]), { securityManager: d };
1745
+ }, Jr = ({
1591
1746
  checkIntervalTokenHasExpired: r = 3e4,
1592
1747
  // Verificar a 30 segundos
1593
1748
  expirationThresholdOfToken: e = 300
1594
1749
  // Antecipar em 5 minutos
1595
1750
  }) => {
1596
- const t = ve(
1597
- (n) => n.get(G.TokenManager)
1598
- ), s = ve(
1599
- (n) => n.get(G.Authenticator)
1600
- ), [o, c] = f(null), [l, i] = f(!1), [u, m] = f(!0), [b, h] = f(!1), [C, E] = f(!1), [y, x] = f(""), [U, _] = f(""), [O, D] = f(null), N = qe(At), k = {
1751
+ const t = Te(
1752
+ (i) => i.get(Y.TokenManager)
1753
+ ), s = Te(
1754
+ (i) => i.get(Y.Authenticator)
1755
+ ), [o, c] = m(null), [l, a] = m(!1), [d, y] = m(!0), [b, u] = m(!1), [C, v] = m(!1), [g, S] = m(""), [P, B] = m(""), [R, z] = m(null), U = it(Ut), h = {
1601
1756
  hasContextualLogin: typeof s.loginWithContext == "function",
1602
1757
  hasFlexibleLogin: typeof s.loginFlexible == "function",
1603
1758
  hasSocialLogin: typeof s.loginSocial == "function",
1604
1759
  hasRegistration: typeof s.register == "function",
1605
1760
  hasContextSupport: typeof t.saveContext == "function"
1606
1761
  };
1607
- z(() => {
1608
- const n = t.getUsername();
1609
- if (n && n != "" && _(n), k.hasContextSupport && t.getContext) {
1610
- const a = t.getContext();
1611
- if (a)
1762
+ J(() => {
1763
+ const i = t.getUsername();
1764
+ if (i && i != "" && B(i), h.hasContextSupport && t.getContext) {
1765
+ const p = t.getContext();
1766
+ if (p)
1612
1767
  try {
1613
- const g = typeof a == "string" ? JSON.parse(a) : a;
1614
- D(g);
1615
- } catch (g) {
1616
- console.warn("Erro ao carregar contexto salvo:", g);
1768
+ const _ = typeof p == "string" ? JSON.parse(p) : p;
1769
+ z(_);
1770
+ } catch (_) {
1771
+ console.warn("Erro ao carregar contexto salvo:", _);
1617
1772
  }
1618
1773
  }
1619
- const w = t.getToken();
1620
- w && (h(!0), x(""), E(!1), c(w)), m(!1);
1774
+ const E = t.getToken();
1775
+ E && (u(!0), S(""), v(!1), c(E)), y(!1);
1621
1776
  }, []);
1622
- const A = () => {
1623
- E(!1), x("");
1624
- }, P = (n) => {
1625
- i(!1), h(!1), t.clearToken(), n && t.clearUsernameAndPassword(), k.hasContextSupport && t.clearContext && t.clearContext(), _(""), D(null), x(""), E(!1), N.clearAllValues();
1626
- }, W = async (n, w, a) => {
1777
+ const w = () => {
1778
+ v(!1), S("");
1779
+ }, D = (i) => {
1780
+ a(!1), u(!1), t.clearToken(), i && t.clearUsernameAndPassword(), h.hasContextSupport && t.clearContext && t.clearContext(), B(""), z(null), S(""), v(!1), U.clearAllValues();
1781
+ }, j = async (i, E, p) => {
1627
1782
  try {
1628
- i(!0), h(!1);
1629
- const g = await s.login(n, w);
1630
- t.saveToken(g), a && t.saveUsernameAndPassword(n, w), t.saveUsername(n), _(n), c(g), i(!1), h(!0);
1631
- } catch (g) {
1632
- i(!1), h(!1), x(ee(g)), E(!0);
1783
+ a(!0), u(!1);
1784
+ const _ = await s.login(i, E);
1785
+ t.saveToken(_), p && t.saveUsernameAndPassword(i, E), t.saveUsername(i), B(i), c(_), a(!1), u(!0);
1786
+ } catch (_) {
1787
+ a(!1), u(!1), S(ie(_)), v(!0);
1633
1788
  }
1634
- }, L = async (n, w = !1) => {
1635
- if (!k.hasContextualLogin || !s.loginWithContext)
1789
+ }, F = async (i, E = !1) => {
1790
+ if (!h.hasContextualLogin || !s.loginWithContext)
1636
1791
  throw new Error("Login contextual não suportado por esta implementação do ArchbaseAuthenticator");
1637
1792
  try {
1638
- i(!0), h(!1);
1639
- const { context: a, user: g, ...T } = await s.loginWithContext(n), j = {
1793
+ a(!0), u(!1);
1794
+ const { context: p, user: _, ...M } = await s.loginWithContext(i), te = {
1640
1795
  scope: "",
1641
- ext_expires_in: T.expires_in,
1642
- ...T
1796
+ ext_expires_in: M.expires_in,
1797
+ ...M
1643
1798
  };
1644
- t.saveToken(j), w ? t.saveUsernameAndPassword(n.email, n.password) : t.clearUsernameAndPassword(), t.saveUsername(n.email), k.hasContextSupport && t.saveContext && a && (t.saveContext(JSON.stringify(a)), D(a)), _(n.email), c(j), i(!1), h(!0);
1645
- } catch (a) {
1646
- throw i(!1), h(!1), x(ee(a)), E(!0), a;
1799
+ t.saveToken(te), E ? t.saveUsernameAndPassword(i.email, i.password) : t.clearUsernameAndPassword(), t.saveUsername(i.email), h.hasContextSupport && t.saveContext && p && (t.saveContext(JSON.stringify(p)), z(p)), B(i.email), c(te), a(!1), u(!0);
1800
+ } catch (p) {
1801
+ throw a(!1), u(!1), S(ie(p)), v(!0), p;
1647
1802
  }
1648
- }, B = async (n, w = !1) => {
1649
- if (!k.hasFlexibleLogin || !s.loginFlexible)
1803
+ }, N = async (i, E = !1) => {
1804
+ if (!h.hasFlexibleLogin || !s.loginFlexible)
1650
1805
  throw new Error("Login flexível não suportado por esta implementação do ArchbaseAuthenticator");
1651
1806
  try {
1652
- i(!0), h(!1);
1653
- const { context: a, user: g, ...T } = await s.loginFlexible(n), j = {
1807
+ a(!0), u(!1);
1808
+ const { context: p, user: _, ...M } = await s.loginFlexible(i), te = {
1654
1809
  scope: "",
1655
- ext_expires_in: T.expires_in,
1656
- ...T
1810
+ ext_expires_in: M.expires_in,
1811
+ ...M
1657
1812
  };
1658
- t.saveToken(j), w && t.saveUsernameAndPassword(n.identifier, n.password), t.saveUsername(g.email || n.identifier), k.hasContextSupport && t.saveContext && a && (t.saveContext(JSON.stringify(a)), D(a)), _(g.email || n.identifier), c(j), i(!1), h(!0);
1659
- } catch (a) {
1660
- throw i(!1), h(!1), x(ee(a)), E(!0), a;
1813
+ t.saveToken(te), E && t.saveUsernameAndPassword(i.identifier, i.password), t.saveUsername(_.email || i.identifier), h.hasContextSupport && t.saveContext && p && (t.saveContext(JSON.stringify(p)), z(p)), B(_.email || i.identifier), c(te), a(!1), u(!0);
1814
+ } catch (p) {
1815
+ throw a(!1), u(!1), S(ie(p)), v(!0), p;
1661
1816
  }
1662
- }, H = async (n) => {
1663
- if (!k.hasSocialLogin || !s.loginSocial)
1817
+ }, Q = async (i) => {
1818
+ if (!h.hasSocialLogin || !s.loginSocial)
1664
1819
  throw new Error("Login social não suportado por esta implementação do ArchbaseAuthenticator");
1665
1820
  try {
1666
- i(!0), h(!1);
1667
- const { context: w, user: a, ...g } = await s.loginSocial(n), T = {
1821
+ a(!0), u(!1);
1822
+ const { context: E, user: p, ..._ } = await s.loginSocial(i), M = {
1668
1823
  scope: "",
1669
- ext_expires_in: g.expires_in,
1670
- ...g
1824
+ ext_expires_in: _.expires_in,
1825
+ ..._
1671
1826
  };
1672
- t.saveToken(T), t.saveUsername(a.email), k.hasContextSupport && t.saveContext && w && (t.saveContext(JSON.stringify(w)), D(w)), _(a.email), c(T), i(!1), h(!0);
1673
- } catch (w) {
1674
- throw i(!1), h(!1), x(ee(w)), E(!0), w;
1827
+ t.saveToken(M), t.saveUsername(p.email), h.hasContextSupport && t.saveContext && E && (t.saveContext(JSON.stringify(E)), z(E)), B(p.email), c(M), a(!1), u(!0);
1828
+ } catch (E) {
1829
+ throw a(!1), u(!1), S(ie(E)), v(!0), E;
1675
1830
  }
1676
- }, Y = async (n) => {
1677
- if (!k.hasRegistration || !s.register)
1831
+ }, Z = async (i) => {
1832
+ if (!h.hasRegistration || !s.register)
1678
1833
  throw new Error("Registro não suportado por esta implementação do ArchbaseAuthenticator");
1679
1834
  try {
1680
- i(!0);
1681
- const w = await s.register(n);
1682
- return i(!1), w;
1683
- } catch (w) {
1684
- throw i(!1), x(ee(w)), E(!0), w;
1835
+ a(!0);
1836
+ const E = await s.register(i);
1837
+ return a(!1), E;
1838
+ } catch (E) {
1839
+ throw a(!1), S(ie(E)), v(!0), E;
1685
1840
  }
1686
- }, $ = async () => s.getSupportedContexts ? await s.getSupportedContexts() : { supportedContexts: ["DEFAULT"], defaultContext: "DEFAULT" }, X = async (n) => s.validateContext ? await s.validateContext(n) : { context: n, supported: n === "DEFAULT" };
1687
- z(() => {
1688
- const n = setInterval(() => {
1689
- o && o.access_token && t.isTokenExpired(o, e) && p();
1841
+ }, K = async () => s.getSupportedContexts ? await s.getSupportedContexts() : { supportedContexts: ["DEFAULT"], defaultContext: "DEFAULT" }, se = async (i) => s.validateContext ? await s.validateContext(i) : { context: i, supported: i === "DEFAULT" };
1842
+ J(() => {
1843
+ const i = setInterval(() => {
1844
+ o && o.access_token && t.isTokenExpired(o, e) && f();
1690
1845
  }, r);
1691
1846
  return () => {
1692
- clearInterval(n);
1847
+ clearInterval(i);
1693
1848
  };
1694
1849
  }, [o]);
1695
- const p = async () => {
1850
+ const f = async () => {
1696
1851
  if (o)
1697
1852
  try {
1698
- const n = await s.refreshToken(o?.refresh_token);
1699
- t.saveToken(n), c(n);
1700
- } catch (n) {
1701
- console.error("Erro ao renovar o token:", n), P();
1853
+ const i = await s.refreshToken(o?.refresh_token);
1854
+ t.saveToken(i), c(i);
1855
+ } catch (i) {
1856
+ console.error("Erro ao renovar o token:", i), D();
1702
1857
  }
1703
1858
  };
1704
1859
  return {
1705
1860
  // Métodos básicos (compatibilidade)
1706
- login: W,
1707
- logout: P,
1708
- username: U,
1861
+ login: j,
1862
+ logout: D,
1863
+ username: P,
1709
1864
  isAuthenticated: b,
1710
1865
  isAuthenticating: l,
1711
- isInitializing: u,
1866
+ isInitializing: d,
1712
1867
  isError: C,
1713
- error: y,
1714
- clearError: A,
1868
+ error: g,
1869
+ clearError: w,
1715
1870
  accessToken: o ? o.access_token : null,
1716
1871
  // Métodos opcionais para autenticação avançada
1717
- loginWithContext: k.hasContextualLogin ? L : void 0,
1718
- loginFlexible: k.hasFlexibleLogin ? B : void 0,
1719
- loginSocial: k.hasSocialLogin ? H : void 0,
1720
- register: k.hasRegistration ? Y : void 0,
1721
- getSupportedContexts: $,
1722
- validateContext: X,
1872
+ loginWithContext: h.hasContextualLogin ? F : void 0,
1873
+ loginFlexible: h.hasFlexibleLogin ? N : void 0,
1874
+ loginSocial: h.hasSocialLogin ? Q : void 0,
1875
+ register: h.hasRegistration ? Z : void 0,
1876
+ getSupportedContexts: K,
1877
+ validateContext: se,
1723
1878
  // Informações de contexto
1724
- context: O,
1879
+ context: R,
1725
1880
  // Detecção de capacidades
1726
- capabilities: k
1881
+ capabilities: h
1727
1882
  };
1728
- }, Mr = () => {
1729
- const r = ve(
1730
- (s) => s.get(G.TokenManager)
1731
- ), [e, t] = f(null);
1732
- return z(() => {
1883
+ }, Kr = () => {
1884
+ const r = Te(
1885
+ (s) => s.get(Y.TokenManager)
1886
+ ), [e, t] = m(null);
1887
+ return J(() => {
1733
1888
  const s = r.getToken();
1734
1889
  s && t(s.access_token);
1735
1890
  }, []), {
1736
1891
  token: e
1737
1892
  };
1738
- }, Or = () => {
1739
- const r = ve(
1740
- (u) => u.get(G.Authenticator)
1741
- ), [e, t] = f(!1), [s, o] = f("");
1893
+ }, Yr = () => {
1894
+ const r = Te(
1895
+ (d) => d.get(Y.Authenticator)
1896
+ ), [e, t] = m(!1), [s, o] = m("");
1742
1897
  return {
1743
- sendResetPasswordEmail: async (u) => {
1898
+ sendResetPasswordEmail: async (d) => {
1744
1899
  try {
1745
- return await r.sendResetPasswordEmail(u);
1746
- } catch (m) {
1747
- throw o(ee(m)), t(!0), m;
1900
+ return await r.sendResetPasswordEmail(d);
1901
+ } catch (y) {
1902
+ throw o(ie(y)), t(!0), y;
1748
1903
  }
1749
1904
  },
1750
- resetPassword: async (u, m, b) => {
1905
+ resetPassword: async (d, y, b) => {
1751
1906
  try {
1752
- return await r.resetPassword(u, m, b);
1753
- } catch (h) {
1754
- throw o(ee(h)), t(!0), h;
1907
+ return await r.resetPassword(d, y, b);
1908
+ } catch (u) {
1909
+ throw o(ie(u)), t(!0), u;
1755
1910
  }
1756
1911
  },
1757
1912
  isError: e,
@@ -1760,36 +1915,36 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
1760
1915
  t(!1), o("");
1761
1916
  }
1762
1917
  };
1763
- }, dr = () => /* @__PURE__ */ d($t, { p: "xl", style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ R(jt, { gap: "md", children: [
1764
- /* @__PURE__ */ R(we, { gap: "sm", children: [
1765
- /* @__PURE__ */ d(Xe, { size: "sm" }),
1766
- /* @__PURE__ */ d(se, { size: "sm", c: "dimmed", children: "Carregando permissões..." })
1918
+ }, Ar = () => /* @__PURE__ */ n(qt, { p: "xl", style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ k(we, { gap: "md", children: [
1919
+ /* @__PURE__ */ k(ae, { gap: "sm", children: [
1920
+ /* @__PURE__ */ n(at, { size: "sm" }),
1921
+ /* @__PURE__ */ n($, { size: "sm", c: "dimmed", children: "Carregando permissões..." })
1767
1922
  ] }),
1768
- /* @__PURE__ */ d(fe, { height: 40, radius: "sm" }),
1769
- /* @__PURE__ */ d(fe, { height: 200, radius: "sm" }),
1770
- /* @__PURE__ */ R(we, { gap: "md", children: [
1771
- /* @__PURE__ */ d(fe, { height: 36, width: 100, radius: "sm" }),
1772
- /* @__PURE__ */ d(fe, { height: 36, width: 100, radius: "sm" })
1923
+ /* @__PURE__ */ n(Se, { height: 40, radius: "sm" }),
1924
+ /* @__PURE__ */ n(Se, { height: 200, radius: "sm" }),
1925
+ /* @__PURE__ */ k(ae, { gap: "md", children: [
1926
+ /* @__PURE__ */ n(Se, { height: 36, width: 100, radius: "sm" }),
1927
+ /* @__PURE__ */ n(Se, { height: 36, width: 100, radius: "sm" })
1773
1928
  ] })
1774
- ] }) }), $e = Re(null), Lr = ({
1929
+ ] }) }), Je = ze(null), qr = ({
1775
1930
  children: r,
1776
1931
  user: e,
1777
1932
  onError: t
1778
1933
  }) => {
1779
- const [s, o] = f(!1), [c, l] = f(null), [i] = f([]), u = e?.isAdministrator || !1, m = pe((y) => u ? !0 : i.includes(y), [i, u]), b = pe((y) => u ? !0 : y.some((x) => i.includes(x)), [i, u]), h = pe((y) => u ? !0 : y.every((x) => i.includes(x)), [i, u]), C = pe((y) => {
1780
- l(y), y && t && t(y);
1781
- }, [t]), E = {
1934
+ const [s, o] = m(!1), [c, l] = m(null), [a] = m([]), d = e?.isAdministrator || !1, y = ke((g) => d ? !0 : a.includes(g), [a, d]), b = ke((g) => d ? !0 : g.some((S) => a.includes(S)), [a, d]), u = ke((g) => d ? !0 : g.every((S) => a.includes(S)), [a, d]), C = ke((g) => {
1935
+ l(g), g && t && t(g);
1936
+ }, [t]), v = {
1782
1937
  user: e,
1783
1938
  isLoading: s,
1784
- hasGlobalPermission: m,
1939
+ hasGlobalPermission: y,
1785
1940
  hasAnyGlobalPermission: b,
1786
- hasAllGlobalPermissions: h,
1787
- isAdmin: u,
1941
+ hasAllGlobalPermissions: u,
1942
+ isAdmin: d,
1788
1943
  error: c,
1789
1944
  setError: C
1790
1945
  };
1791
- return /* @__PURE__ */ d($e.Provider, { value: E, children: r });
1792
- }, bt = Re(null), ur = ({
1946
+ return /* @__PURE__ */ n(Je.Provider, { value: v, children: r });
1947
+ }, Dt = ze(null), Er = ({
1793
1948
  children: r,
1794
1949
  resourceName: e,
1795
1950
  resourceDescription: t,
@@ -1797,97 +1952,97 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
1797
1952
  fallbackComponent: o,
1798
1953
  loadingComponent: c,
1799
1954
  onSecurityReady: l,
1800
- onError: i
1955
+ onError: a
1801
1956
  }) => {
1802
- const u = Ne($e);
1803
- if (!u)
1957
+ const d = je(Je);
1958
+ if (!d)
1804
1959
  throw new Error("ArchbaseViewSecurityProvider deve ser usado dentro de um ArchbaseSecurityProvider");
1805
- const { user: m, isAdmin: b } = u, [h, C] = f(null), [E, y] = f(!0), [x, U] = f(null);
1806
- if (Ge.useEffect(() => {
1807
- if (!m) {
1808
- y(!1);
1960
+ const { user: y, isAdmin: b } = d, [u, C] = m(null), [v, g] = m(!0), [S, P] = m(null);
1961
+ if (st.useEffect(() => {
1962
+ if (!y) {
1963
+ g(!1);
1809
1964
  return;
1810
1965
  }
1811
- const A = new nt(e, t, b);
1966
+ const w = new ft(e, t, b);
1812
1967
  (async () => {
1813
- y(!0);
1968
+ g(!0);
1814
1969
  try {
1815
- await A.apply(() => {
1816
- C(A), y(!1), l && l(A);
1970
+ await w.apply(() => {
1971
+ C(w), g(!1), l && l(w);
1817
1972
  });
1818
1973
  } catch {
1819
- const L = A.getError() || "Erro ao carregar permissões";
1820
- U(L), y(!1), i && i(L);
1974
+ const F = w.getError() || "Erro ao carregar permissões";
1975
+ P(F), g(!1), a && a(F);
1821
1976
  }
1822
1977
  })();
1823
- }, [e, t, m, b, l, i]), E)
1824
- return c ? /* @__PURE__ */ d(te, { children: c }) : /* @__PURE__ */ d(dr, {});
1825
- if (x)
1826
- return /* @__PURE__ */ d("div", { className: "archbase-security-error", children: /* @__PURE__ */ R("div", { children: [
1978
+ }, [e, t, y, b, l, a]), v)
1979
+ return c ? /* @__PURE__ */ n(re, { children: c }) : /* @__PURE__ */ n(Ar, {});
1980
+ if (S)
1981
+ return /* @__PURE__ */ n("div", { className: "archbase-security-error", children: /* @__PURE__ */ k("div", { children: [
1827
1982
  "Erro ao carregar permissões: ",
1828
- x
1983
+ S
1829
1984
  ] }) });
1830
- if (!m)
1831
- return o || /* @__PURE__ */ d("div", { className: "archbase-security-no-user", children: /* @__PURE__ */ d("div", { children: "É necessário fazer login para acessar esta área" }) });
1832
- if (s.length > 0 && h && !s.every(
1833
- (P) => h.hasPermission(P)
1985
+ if (!y)
1986
+ return o || /* @__PURE__ */ n("div", { className: "archbase-security-no-user", children: /* @__PURE__ */ n("div", { children: "É necessário fazer login para acessar esta área" }) });
1987
+ if (s.length > 0 && u && !s.every(
1988
+ (D) => u.hasPermission(D)
1834
1989
  ))
1835
- return o || /* @__PURE__ */ R("div", { className: "archbase-security-access-denied", children: [
1836
- /* @__PURE__ */ d("div", { children: "Você não possui permissão para acessar esta área" }),
1837
- /* @__PURE__ */ R("small", { children: [
1990
+ return o || /* @__PURE__ */ k("div", { className: "archbase-security-access-denied", children: [
1991
+ /* @__PURE__ */ n("div", { children: "Você não possui permissão para acessar esta área" }),
1992
+ /* @__PURE__ */ k("small", { children: [
1838
1993
  "Permissões necessárias: ",
1839
1994
  s.join(", ")
1840
1995
  ] })
1841
1996
  ] });
1842
- const k = {
1843
- securityManager: h,
1844
- hasPermission: (A) => h?.hasPermission(A) || !1,
1845
- hasAnyPermission: (A) => A.some((P) => h?.hasPermission(P) || !1),
1846
- hasAllPermissions: (A) => A.every((P) => h?.hasPermission(P) || !1),
1847
- registerAction: (A, P) => {
1848
- h?.registerAction(A, P);
1997
+ const h = {
1998
+ securityManager: u,
1999
+ hasPermission: (w) => u?.hasPermission(w) || !1,
2000
+ hasAnyPermission: (w) => w.some((D) => u?.hasPermission(D) || !1),
2001
+ hasAllPermissions: (w) => w.every((D) => u?.hasPermission(D) || !1),
2002
+ registerAction: (w, D) => {
2003
+ u?.registerAction(w, D);
1849
2004
  },
1850
- isLoading: E,
1851
- error: x
2005
+ isLoading: v,
2006
+ error: S
1852
2007
  };
1853
- return /* @__PURE__ */ d(bt.Provider, { value: k, children: r });
1854
- }, hr = () => {
1855
- const r = Ne($e);
2008
+ return /* @__PURE__ */ n(Dt.Provider, { value: h, children: r });
2009
+ }, xr = () => {
2010
+ const r = je(Je);
1856
2011
  if (!r)
1857
2012
  throw new Error("useArchbaseSecurity deve ser usado dentro de um ArchbaseSecurityProvider");
1858
2013
  return r;
1859
- }, je = () => {
1860
- const r = Ne(bt);
2014
+ }, Ke = () => {
2015
+ const r = je(Dt);
1861
2016
  if (!r)
1862
2017
  throw new Error("useArchbaseViewSecurity deve ser usado dentro de um ArchbaseViewSecurityProvider");
1863
2018
  return r;
1864
- }, $r = (r, e) => {
1865
- const t = je(), { hasPermission: s, hasAnyPermission: o, hasAllPermissions: c, registerAction: l, securityManager: i, isLoading: u, error: m } = t;
1866
- return Ge.useEffect(() => {
2019
+ }, Xr = (r, e) => {
2020
+ const t = Ke(), { hasPermission: s, hasAnyPermission: o, hasAllPermissions: c, registerAction: l, securityManager: a, isLoading: d, error: y } = t;
2021
+ return st.useEffect(() => {
1867
2022
  r && e && (l("create", `Criar ${e}`), l("edit", `Editar ${e}`), l("delete", `Deletar ${e}`), l("view", `Visualizar ${e}`), l("list", `Listar ${e}`));
1868
2023
  }, [r, e, l]), {
1869
2024
  hasPermission: s,
1870
2025
  hasAnyPermission: o,
1871
2026
  hasAllPermissions: c,
1872
2027
  registerAction: l,
1873
- securityManager: i,
2028
+ securityManager: a,
1874
2029
  canCreate: s("create"),
1875
2030
  canEdit: s("edit"),
1876
2031
  canDelete: s("delete"),
1877
2032
  canView: s("view"),
1878
2033
  canList: s("list"),
1879
- isLoading: u,
1880
- error: m
2034
+ isLoading: d,
2035
+ error: y
1881
2036
  };
1882
- }, jr = () => {
1883
- const r = je();
2037
+ }, Qr = () => {
2038
+ const r = Ke();
1884
2039
  return {
1885
2040
  check: r.hasPermission,
1886
2041
  checkAny: r.hasAnyPermission,
1887
2042
  checkAll: r.hasAllPermissions,
1888
- isAdmin: hr().isAdmin
2043
+ isAdmin: xr().isAdmin
1889
2044
  };
1890
- }, Et = ({
2045
+ }, _t = ({
1891
2046
  children: r,
1892
2047
  actionName: e,
1893
2048
  requiredPermissions: t = [],
@@ -1896,13 +2051,13 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
1896
2051
  fallback: c = null,
1897
2052
  autoRegister: l = !0
1898
2053
  }) => {
1899
- const { hasPermission: i, hasAnyPermission: u, hasAllPermissions: m, registerAction: b } = je();
1900
- z(() => {
2054
+ const { hasPermission: a, hasAnyPermission: d, hasAllPermissions: y, registerAction: b } = Ke();
2055
+ J(() => {
1901
2056
  l && e && o && b(e, o);
1902
2057
  }, [e, o, l, b]);
1903
- let h = !1;
1904
- return e ? h = i(e) : t.length > 0 ? h = s ? m(t) : u(t) : h = !0, h ? /* @__PURE__ */ d(te, { children: r }) : /* @__PURE__ */ d(te, { children: c });
1905
- }, Fr = ({
2058
+ let u = !1;
2059
+ return e ? u = a(e) : t.length > 0 ? u = s ? y(t) : d(t) : u = !0, u ? /* @__PURE__ */ n(re, { children: r }) : /* @__PURE__ */ n(re, { children: c });
2060
+ }, Zr = ({
1906
2061
  actionName: r,
1907
2062
  actionDescription: e,
1908
2063
  children: t,
@@ -1910,19 +2065,19 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
1910
2065
  disabled: o = !1,
1911
2066
  className: c = "",
1912
2067
  style: l = {},
1913
- variant: i = "primary",
1914
- size: u = "medium",
1915
- type: m = "button"
2068
+ variant: a = "primary",
2069
+ size: d = "medium",
2070
+ type: y = "button"
1916
2071
  }) => {
1917
2072
  const b = () => {
1918
- const C = "archbase-secure-btn", E = `archbase-secure-btn--${i}`, y = `archbase-secure-btn--${u}`;
1919
- return `${C} ${E} ${y} ${c}`.trim();
1920
- }, h = () => {
2073
+ const C = "archbase-secure-btn", v = `archbase-secure-btn--${a}`, g = `archbase-secure-btn--${d}`;
2074
+ return `${C} ${v} ${g} ${c}`.trim();
2075
+ }, u = () => {
1921
2076
  const C = {
1922
2077
  small: { padding: "4px 8px", fontSize: "12px" },
1923
2078
  medium: { padding: "8px 16px", fontSize: "14px" },
1924
2079
  large: { padding: "12px 24px", fontSize: "16px" }
1925
- }, E = {
2080
+ }, v = {
1926
2081
  primary: { backgroundColor: "#007bff", color: "white" },
1927
2082
  secondary: { backgroundColor: "#6c757d", color: "white" },
1928
2083
  danger: { backgroundColor: "#dc3545", color: "white" },
@@ -1935,31 +2090,31 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
1935
2090
  cursor: o ? "not-allowed" : "pointer",
1936
2091
  fontWeight: "500",
1937
2092
  opacity: o ? 0.6 : 1,
1938
- ...C[u],
1939
- ...E[i],
2093
+ ...C[d],
2094
+ ...v[a],
1940
2095
  ...l
1941
2096
  };
1942
2097
  };
1943
- return /* @__PURE__ */ d(
1944
- Et,
2098
+ return /* @__PURE__ */ n(
2099
+ _t,
1945
2100
  {
1946
2101
  actionName: r,
1947
2102
  actionDescription: e,
1948
2103
  fallback: null,
1949
- children: /* @__PURE__ */ d(
2104
+ children: /* @__PURE__ */ n(
1950
2105
  "button",
1951
2106
  {
1952
- type: m,
2107
+ type: y,
1953
2108
  onClick: s,
1954
2109
  disabled: o,
1955
2110
  className: b(),
1956
- style: h(),
2111
+ style: u(),
1957
2112
  children: t
1958
2113
  }
1959
2114
  )
1960
2115
  }
1961
2116
  );
1962
- }, Vr = ({
2117
+ }, es = ({
1963
2118
  children: r,
1964
2119
  actionName: e,
1965
2120
  actionDescription: t,
@@ -1967,12 +2122,12 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
1967
2122
  label: o,
1968
2123
  fallbackText: c = "Campo não disponível",
1969
2124
  fallbackComponent: l
1970
- }) => e ? /* @__PURE__ */ d(
1971
- Et,
2125
+ }) => e ? /* @__PURE__ */ n(
2126
+ _t,
1972
2127
  {
1973
2128
  actionName: e,
1974
2129
  actionDescription: t,
1975
- fallback: l || /* @__PURE__ */ R("div", { className: "archbase-secure-field-fallback", style: {
2130
+ fallback: l || /* @__PURE__ */ k("div", { className: "archbase-secure-field-fallback", style: {
1976
2131
  padding: "8px",
1977
2132
  color: "#666",
1978
2133
  fontStyle: "italic",
@@ -1980,7 +2135,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
1980
2135
  border: "1px dashed #dee2e6",
1981
2136
  borderRadius: "4px"
1982
2137
  }, children: [
1983
- s && o && /* @__PURE__ */ R("label", { style: { fontWeight: "bold" }, children: [
2138
+ s && o && /* @__PURE__ */ k("label", { style: { fontWeight: "bold" }, children: [
1984
2139
  o,
1985
2140
  ": "
1986
2141
  ] }),
@@ -1988,91 +2143,92 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
1988
2143
  ] }),
1989
2144
  children: r
1990
2145
  }
1991
- ) : /* @__PURE__ */ d(te, { children: r });
1992
- function zr(r, e) {
2146
+ ) : /* @__PURE__ */ n(re, { children: r });
2147
+ function ts(r, e) {
1993
2148
  return function(s) {
1994
- const { resourceName: o, resourceDescription: c, requiredPermissions: l, fallbackComponent: i } = e;
1995
- return /* @__PURE__ */ d(
1996
- ur,
2149
+ const { resourceName: o, resourceDescription: c, requiredPermissions: l, fallbackComponent: a } = e;
2150
+ return /* @__PURE__ */ n(
2151
+ Er,
1997
2152
  {
1998
2153
  resourceName: o,
1999
2154
  resourceDescription: c,
2000
2155
  requiredPermissions: l,
2001
- fallbackComponent: i,
2002
- children: /* @__PURE__ */ d(r, { ...s })
2156
+ fallbackComponent: a,
2157
+ children: /* @__PURE__ */ n(r, { ...s })
2003
2158
  }
2004
2159
  );
2005
2160
  };
2006
2161
  }
2007
2162
  export {
2008
- At as ARCHBASE_SECURITY_MANAGER_STORE,
2009
- ir as AccessIntervalDto,
2010
- ct as AccessScheduleDto,
2011
- Le as AccessTokenDto,
2012
- ar as ActionDto,
2013
- Oe as ApiTokenDto,
2014
- wt as ArchbaseAccessTokenService,
2015
- yt as ArchbaseApiTokenService,
2016
- sr as ArchbaseAuthContext,
2017
- Cr as ArchbaseAuthProvider,
2018
- mt as ArchbaseGroupService,
2019
- Dr as ArchbaseLogin,
2020
- gt as ArchbaseProfileService,
2021
- Et as ArchbaseProtectedComponent,
2022
- Rr as ArchbaseResetPassword,
2023
- vt as ArchbaseResourceService,
2024
- Fr as ArchbaseSecureActionButton,
2025
- Vr as ArchbaseSecureFormField,
2026
- nt as ArchbaseSecurityManager,
2027
- Lr as ArchbaseSecurityProvider,
2028
- V as ArchbaseTenantManager,
2029
- Ze as ArchbaseUser,
2030
- ft as ArchbaseUserService,
2031
- et as ArchbaseUsernameAndPassword,
2032
- et as ArchbaseUsernameAndPasswordImpl,
2033
- ur as ArchbaseViewSecurityProvider,
2034
- Te as CONTEXT_STORAGE_KEY,
2035
- Vt as DefaultArchbaseTokenManager,
2036
- dr as DefaultSecurityLoading,
2037
- Q as ENCRYPTION_KEY,
2038
- rt as FetchError,
2039
- he as GroupDto,
2040
- _r as PermissionDto,
2041
- ue as ProfileDto,
2042
- ht as ResourceDto,
2043
- le as SecurityDto,
2044
- ae as SecurityType,
2045
- Se as TOKEN_COOKIE_NAME,
2046
- nr as TipoRecurso,
2047
- Pe as USER_NAME,
2048
- Ie as USER_NAME_AND_PASSWORD,
2049
- Ee as UserDto,
2050
- Be as UserGroupDto,
2051
- Zt as createInternalConfig,
2052
- ge as decodeJWT,
2053
- oe as epochAtSecondsFromNow,
2054
- He as epochTimeIsPast,
2055
- qt as fetchTokens,
2056
- Yt as fetchWithRefreshToken,
2057
- Wt as generateCodeChallenge,
2058
- zt as generateRandomString,
2059
- tt as getRandomInteger,
2060
- rr as getRefreshExpiresIn,
2061
- Gt as postWithXForm,
2062
- Jt as redirectToLogin,
2063
- Xt as redirectToLogout,
2064
- Br as useArchbaseAuthenticationManager,
2065
- Mr as useArchbaseGetCurrentToken,
2066
- lr as useArchbaseGetLoggedUser,
2067
- jr as useArchbasePermissionCheck,
2068
- Or as useArchbaseResetPassword,
2069
- $r as useArchbaseSecureForm,
2070
- hr as useArchbaseSecurity,
2071
- Nr as useArchbaseSecurityManager,
2072
- Ur as useArchbaseTenantManager,
2073
- je as useArchbaseViewSecurity,
2074
- Tr as useBrowserStorage,
2075
- er as validateConfig,
2076
- Qt as validateState,
2077
- zr as withArchbaseSecurity
2163
+ Ut as ARCHBASE_SECURITY_MANAGER_STORE,
2164
+ yr as AccessIntervalDto,
2165
+ wt as AccessScheduleDto,
2166
+ Ge as AccessTokenDto,
2167
+ wr as ActionDto,
2168
+ He as ApiTokenDto,
2169
+ Pt as ArchbaseAccessTokenService,
2170
+ Ct as ArchbaseApiTokenService,
2171
+ mr as ArchbaseAuthContext,
2172
+ zr as ArchbaseAuthProvider,
2173
+ St as ArchbaseGroupService,
2174
+ Vr as ArchbaseLogin,
2175
+ Wr as ArchbaseMfaSetup,
2176
+ It as ArchbaseProfileService,
2177
+ _t as ArchbaseProtectedComponent,
2178
+ Hr as ArchbaseResetPassword,
2179
+ Tt as ArchbaseResourceService,
2180
+ Zr as ArchbaseSecureActionButton,
2181
+ es as ArchbaseSecureFormField,
2182
+ ft as ArchbaseSecurityManager,
2183
+ qr as ArchbaseSecurityProvider,
2184
+ G as ArchbaseTenantManager,
2185
+ lt as ArchbaseUser,
2186
+ kt as ArchbaseUserService,
2187
+ dt as ArchbaseUsernameAndPassword,
2188
+ dt as ArchbaseUsernameAndPasswordImpl,
2189
+ Er as ArchbaseViewSecurityProvider,
2190
+ Me as CONTEXT_STORAGE_KEY,
2191
+ Zt as DefaultArchbaseTokenManager,
2192
+ Ar as DefaultSecurityLoading,
2193
+ oe as ENCRYPTION_KEY,
2194
+ ht as FetchError,
2195
+ Ae as GroupDto,
2196
+ Fr as PermissionDto,
2197
+ be as ProfileDto,
2198
+ Et as ResourceDto,
2199
+ me as SecurityDto,
2200
+ he as SecurityType,
2201
+ Re as TOKEN_COOKIE_NAME,
2202
+ gr as TipoRecurso,
2203
+ Be as USER_NAME,
2204
+ Ne as USER_NAME_AND_PASSWORD,
2205
+ _e as UserDto,
2206
+ Ve as UserGroupDto,
2207
+ dr as createInternalConfig,
2208
+ Ce as decodeJWT,
2209
+ de as epochAtSecondsFromNow,
2210
+ rt as epochTimeIsPast,
2211
+ ir as fetchTokens,
2212
+ ar as fetchWithRefreshToken,
2213
+ tr as generateCodeChallenge,
2214
+ er as generateRandomString,
2215
+ ut as getRandomInteger,
2216
+ pr as getRefreshExpiresIn,
2217
+ sr as postWithXForm,
2218
+ or as redirectToLogin,
2219
+ cr as redirectToLogout,
2220
+ Jr as useArchbaseAuthenticationManager,
2221
+ Kr as useArchbaseGetCurrentToken,
2222
+ br as useArchbaseGetLoggedUser,
2223
+ Qr as useArchbasePermissionCheck,
2224
+ Yr as useArchbaseResetPassword,
2225
+ Xr as useArchbaseSecureForm,
2226
+ xr as useArchbaseSecurity,
2227
+ Gr as useArchbaseSecurityManager,
2228
+ jr as useArchbaseTenantManager,
2229
+ Ke as useArchbaseViewSecurity,
2230
+ $r as useBrowserStorage,
2231
+ ur as validateConfig,
2232
+ lr as validateState,
2233
+ ts as withArchbaseSecurity
2078
2234
  };