@nice2dev/auth 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,399 +1,409 @@
1
- import { useState as g, useCallback as $, forwardRef as j, useMemo as ne, useRef as H, useEffect as Q, useImperativeHandle as oe } from "react";
2
- import { jsxs as a, jsx as e, Fragment as ae } from "react/jsx-runtime";
3
- function Re(r = {}) {
4
- const { onLogin: t, onRefresh: c, onLogout: n, storageKey: i = "nice_auth", persistAuth: h = !1 } = r, [l, s] = g(() => {
5
- if (h && typeof window < "u")
1
+ import { useState as _, useCallback as M, forwardRef as K, useMemo as se, useRef as Q, useEffect as Z, useImperativeHandle as me } from "react";
2
+ import { jsxs as r, jsx as e, Fragment as ce } from "react/jsx-runtime";
3
+ import { useNiceTranslation as q } from "@nice2dev/ui-core";
4
+ function Se(s = {}) {
5
+ const { onLogin: a, onRefresh: n, onLogout: t, storageKey: i = "nice_auth", persistAuth: d = !1 } = s, [l, c] = _(() => {
6
+ if (d && typeof window < "u")
6
7
  try {
7
- const o = localStorage.getItem(i);
8
- if (o)
9
- return { ...JSON.parse(o), loading: !1, error: null };
8
+ const m = localStorage.getItem(i);
9
+ if (m)
10
+ return { ...JSON.parse(m), loading: !1, error: null };
10
11
  } catch {
11
12
  }
12
13
  return { isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null };
13
- }), u = $(
14
- (o) => {
15
- s((p) => {
16
- const f = { ...p, ...o };
17
- return h && typeof window < "u" && (f.isAuthenticated ? localStorage.setItem(
14
+ }), h = M(
15
+ (m) => {
16
+ c((p) => {
17
+ const b = { ...p, ...m };
18
+ return d && typeof window < "u" && (b.isAuthenticated ? localStorage.setItem(
18
19
  i,
19
- JSON.stringify({ isAuthenticated: !0, user: f.user })
20
- ) : localStorage.removeItem(i)), f;
20
+ JSON.stringify({ isAuthenticated: !0, user: b.user })
21
+ ) : localStorage.removeItem(i)), b;
21
22
  });
22
23
  },
23
- [h, i]
24
- ), S = $(
25
- async (o, p) => {
26
- u({ loading: !0, error: null });
24
+ [d, i]
25
+ ), x = M(
26
+ async (m, p) => {
27
+ h({ loading: !0, error: null });
27
28
  try {
28
- if (t) {
29
- const f = await t(o, p);
30
- return u({
29
+ if (a) {
30
+ const b = await a(m, p);
31
+ return h({
31
32
  isAuthenticated: !0,
32
- user: f.user,
33
- tokens: f.tokens,
33
+ user: b.user,
34
+ tokens: b.tokens,
34
35
  loading: !1
35
36
  }), !0;
36
37
  }
37
- return u({ loading: !1, error: "No login handler configured" }), !1;
38
- } catch (f) {
39
- return u({
38
+ return h({ loading: !1, error: "No login handler configured" }), !1;
39
+ } catch (b) {
40
+ return h({
40
41
  loading: !1,
41
- error: (f == null ? void 0 : f.message) ?? "Login failed"
42
+ error: (b == null ? void 0 : b.message) ?? "Login failed"
42
43
  }), !1;
43
44
  }
44
45
  },
45
- [t, u]
46
- ), d = $(() => {
47
- n == null || n(), u({ isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null });
48
- }, [n, u]), A = $(async () => {
49
- var o;
50
- if (!((o = l.tokens) != null && o.refreshToken) || !c)
46
+ [a, h]
47
+ ), f = M(() => {
48
+ t == null || t(), h({ isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null });
49
+ }, [t, h]), g = M(async () => {
50
+ var m;
51
+ if (!((m = l.tokens) != null && m.refreshToken) || !n)
51
52
  return !1;
52
53
  try {
53
- const p = await c(l.tokens.refreshToken);
54
- return u({ tokens: p }), !0;
54
+ const p = await n(l.tokens.refreshToken);
55
+ return h({ tokens: p }), !0;
55
56
  } catch {
56
- return d(), !1;
57
+ return f(), !1;
57
58
  }
58
- }, [l.tokens, c, u, d]), b = $(
59
- (o, p) => {
60
- u({ isAuthenticated: !0, user: o, tokens: p, loading: !1, error: null });
59
+ }, [l.tokens, n, h, f]), S = M(
60
+ (m, p) => {
61
+ h({ isAuthenticated: !0, user: m, tokens: p, loading: !1, error: null });
61
62
  },
62
- [u]
63
- ), k = $(
64
- (...o) => l.user ? o.every((p) => l.user.roles.includes(p)) : !1,
63
+ [h]
64
+ ), y = M(
65
+ (...m) => l.user ? m.every((p) => l.user.roles.includes(p)) : !1,
65
66
  [l.user]
66
- ), _ = $(
67
- (...o) => l.user ? o.every((p) => l.user.permissions.includes(p)) : !1,
67
+ ), o = M(
68
+ (...m) => l.user ? m.every((p) => l.user.permissions.includes(p)) : !1,
68
69
  [l.user]
69
- ), F = $(() => {
70
- u({ error: null });
71
- }, [u]);
70
+ ), w = M(() => {
71
+ h({ error: null });
72
+ }, [h]);
72
73
  return {
73
74
  ...l,
74
- login: S,
75
- logout: d,
76
- refreshToken: A,
77
- setAuth: b,
78
- hasRoles: k,
79
- hasPermissions: _,
80
- clearError: F
75
+ login: x,
76
+ logout: f,
77
+ refreshToken: g,
78
+ setAuth: S,
79
+ hasRoles: y,
80
+ hasPermissions: o,
81
+ clearError: w
81
82
  };
82
83
  }
83
- const de = j(
84
- ({
85
- onSubmit: r,
86
- loading: t = !1,
87
- error: c,
88
- showRememberMe: n = !0,
89
- showForgotPassword: i = !0,
90
- onForgotPassword: h,
91
- showRegisterLink: l = !0,
92
- onRegisterClick: s,
93
- title: u = "Sign In",
94
- submitLabel: S = "Sign In",
95
- logo: d,
96
- footer: A,
97
- className: b,
98
- style: k,
99
- emailLabel: _ = "Email",
100
- passwordLabel: F = "Password",
101
- tracelessPolicy: o,
102
- privacyMessage: p
103
- }, f) => {
104
- const [M, w] = g(""), [C, T] = g(""), [E, N] = g(!1), I = ne(() => !(!n || o && !o.cookiesAllowed), [n, o]), L = $(
105
- (x) => {
106
- x.preventDefault();
107
- const D = (o == null ? void 0 : o.cookiesAllowed) === !1 ? !1 : E;
108
- r == null || r({ email: M, password: C, rememberMe: D });
109
- },
110
- [M, C, E, r, o]
111
- );
112
- return /* @__PURE__ */ a(
113
- "form",
114
- {
115
- ref: f,
116
- className: `nice-login-form${b ? ` ${b}` : ""}`,
117
- style: k,
118
- onSubmit: L,
119
- noValidate: !0,
120
- children: [
121
- d && /* @__PURE__ */ e("div", { className: "nice-login-form__logo", children: d }),
122
- /* @__PURE__ */ e("h2", { className: "nice-login-form__title", children: u }),
123
- c && /* @__PURE__ */ e("div", { className: "nice-login-form__error", role: "alert", children: c }),
124
- /* @__PURE__ */ a("div", { className: "nice-login-form__field", children: [
125
- /* @__PURE__ */ e("label", { htmlFor: "nice-login-email", children: _ }),
126
- /* @__PURE__ */ e(
127
- "input",
128
- {
129
- id: "nice-login-email",
130
- className: "nice-input",
131
- type: "email",
132
- value: M,
133
- onChange: (x) => w(x.target.value),
134
- autoComplete: "email",
135
- required: !0,
136
- disabled: t
137
- }
138
- )
139
- ] }),
140
- /* @__PURE__ */ a("div", { className: "nice-login-form__field", children: [
141
- /* @__PURE__ */ e("label", { htmlFor: "nice-login-password", children: F }),
142
- /* @__PURE__ */ e(
143
- "input",
144
- {
145
- id: "nice-login-password",
146
- className: "nice-input",
147
- type: "password",
148
- value: C,
149
- onChange: (x) => T(x.target.value),
150
- autoComplete: "current-password",
151
- required: !0,
152
- disabled: t
153
- }
154
- )
155
- ] }),
156
- /* @__PURE__ */ a("div", { className: "nice-login-form__options", children: [
157
- I && /* @__PURE__ */ a("label", { className: "nice-login-form__remember", children: [
84
+ const Te = /* @__PURE__ */ Object.assign(
85
+ /* @__PURE__ */ K(
86
+ ({
87
+ onSubmit: s,
88
+ loading: a = !1,
89
+ error: n,
90
+ showRememberMe: t = !0,
91
+ showForgotPassword: i = !0,
92
+ onForgotPassword: d,
93
+ showRegisterLink: l = !0,
94
+ onRegisterClick: c,
95
+ title: h,
96
+ submitLabel: x,
97
+ logo: f,
98
+ footer: g,
99
+ className: S,
100
+ style: y,
101
+ emailLabel: o,
102
+ passwordLabel: w,
103
+ tracelessPolicy: m,
104
+ privacyMessage: p
105
+ }, b) => {
106
+ const { t: N } = q(), [I, k] = _(""), [T, $] = _(""), [O, v] = _(!1), E = se(() => !(!t || m && !m.cookiesAllowed), [t, m]), L = M(
107
+ (A) => {
108
+ A.preventDefault();
109
+ const D = (m == null ? void 0 : m.cookiesAllowed) === !1 ? !1 : O;
110
+ s == null || s({ email: I, password: T, rememberMe: D });
111
+ },
112
+ [I, T, O, s, m]
113
+ );
114
+ return /* @__PURE__ */ r(
115
+ "form",
116
+ {
117
+ ref: b,
118
+ className: `nice-login-form${S ? ` ${S}` : ""}`,
119
+ style: y,
120
+ onSubmit: L,
121
+ noValidate: !0,
122
+ children: [
123
+ f && /* @__PURE__ */ e("div", { className: "nice-login-form__logo", children: f }),
124
+ /* @__PURE__ */ e("h2", { className: "nice-login-form__title", children: h ?? N("loginForm.title", "Sign In") }),
125
+ n && /* @__PURE__ */ e("div", { className: "nice-login-form__error", role: "alert", children: n }),
126
+ /* @__PURE__ */ r("div", { className: "nice-login-form__field", children: [
127
+ /* @__PURE__ */ e("label", { htmlFor: "nice-login-email", children: o ?? N("loginForm.email", "Email") }),
158
128
  /* @__PURE__ */ e(
159
129
  "input",
160
130
  {
161
- type: "checkbox",
162
- checked: E,
163
- onChange: (x) => N(x.target.checked),
164
- disabled: t
131
+ id: "nice-login-email",
132
+ className: "nice-input",
133
+ type: "email",
134
+ value: I,
135
+ onChange: (A) => k(A.target.value),
136
+ autoComplete: "email",
137
+ required: !0,
138
+ disabled: a
165
139
  }
166
- ),
167
- /* @__PURE__ */ e("span", { children: "Remember me" })
140
+ )
141
+ ] }),
142
+ /* @__PURE__ */ r("div", { className: "nice-login-form__field", children: [
143
+ /* @__PURE__ */ e("label", { htmlFor: "nice-login-password", children: w ?? N("loginForm.password", "Password") }),
144
+ /* @__PURE__ */ e(
145
+ "input",
146
+ {
147
+ id: "nice-login-password",
148
+ className: "nice-input",
149
+ type: "password",
150
+ value: T,
151
+ onChange: (A) => $(A.target.value),
152
+ autoComplete: "current-password",
153
+ required: !0,
154
+ disabled: a
155
+ }
156
+ )
168
157
  ] }),
169
- !I && n && p && /* @__PURE__ */ e("span", { className: "nice-login-form__privacy-notice", children: p }),
170
- i && /* @__PURE__ */ e(
158
+ /* @__PURE__ */ r("div", { className: "nice-login-form__options", children: [
159
+ E && /* @__PURE__ */ r("label", { className: "nice-login-form__remember", children: [
160
+ /* @__PURE__ */ e(
161
+ "input",
162
+ {
163
+ type: "checkbox",
164
+ checked: O,
165
+ onChange: (A) => v(A.target.checked),
166
+ disabled: a
167
+ }
168
+ ),
169
+ /* @__PURE__ */ e("span", { children: N("loginForm.rememberMe", "Remember me") })
170
+ ] }),
171
+ !E && t && p && /* @__PURE__ */ e("span", { className: "nice-login-form__privacy-notice", children: p }),
172
+ i && /* @__PURE__ */ e(
173
+ "button",
174
+ {
175
+ type: "button",
176
+ className: "nice-login-form__forgot",
177
+ onClick: d,
178
+ disabled: a,
179
+ children: N("loginForm.forgotPassword", "Forgot password?")
180
+ }
181
+ )
182
+ ] }),
183
+ /* @__PURE__ */ e(
171
184
  "button",
172
185
  {
173
- type: "button",
174
- className: "nice-login-form__forgot",
175
- onClick: h,
176
- disabled: t,
177
- children: "Forgot password?"
186
+ type: "submit",
187
+ className: "nice-btn nice-btn--primary nice-login-form__submit",
188
+ disabled: a || !I || !T,
189
+ children: a ? "…" : x ?? N("loginForm.signIn", "Sign In")
178
190
  }
179
- )
180
- ] }),
181
- /* @__PURE__ */ e(
182
- "button",
183
- {
184
- type: "submit",
185
- className: "nice-btn nice-btn--primary nice-login-form__submit",
186
- disabled: t || !M || !C,
187
- children: t ? "…" : S
188
- }
189
- ),
190
- l && /* @__PURE__ */ a("div", { className: "nice-login-form__register", children: [
191
- /* @__PURE__ */ e("span", { children: "Don't have an account? " }),
192
- /* @__PURE__ */ e("button", { type: "button", onClick: s, disabled: t, children: "Register" })
193
- ] }),
194
- A && /* @__PURE__ */ e("div", { className: "nice-login-form__footer", children: A })
195
- ]
196
- }
197
- );
198
- }
199
- );
200
- de.displayName = "NiceLoginForm";
201
- const he = {
191
+ ),
192
+ l && /* @__PURE__ */ r("div", { className: "nice-login-form__register", children: [
193
+ /* @__PURE__ */ r("span", { children: [
194
+ N("loginForm.dontHaveAnAccount", "Don't have an account?"),
195
+ " "
196
+ ] }),
197
+ /* @__PURE__ */ e("button", { type: "button", onClick: c, disabled: a, children: N("loginForm.register", "Register") })
198
+ ] }),
199
+ g && /* @__PURE__ */ e("div", { className: "nice-login-form__footer", children: g })
200
+ ]
201
+ }
202
+ );
203
+ }
204
+ ),
205
+ { displayName: "NiceLoginForm" }
206
+ ), ue = {
202
207
  0: "Very weak",
203
208
  1: "Weak",
204
209
  2: "Fair",
205
210
  3: "Strong",
206
211
  4: "Very strong"
207
- }, ue = {
212
+ }, pe = {
208
213
  0: "#d9534f",
209
214
  1: "#f0ad4e",
210
215
  2: "#5bc0de",
211
216
  3: "#5cb85c",
212
217
  4: "#2e7d32"
213
218
  };
214
- function Y(r) {
215
- if (!r)
219
+ function ee(s) {
220
+ if (!s)
216
221
  return 0;
217
- let t = 0;
218
- return r.length >= 8 && t++, r.length >= 12 && t++, /[a-z]/.test(r) && /[A-Z]/.test(r) && t++, /\d/.test(r) && t++, /[^a-zA-Z0-9]/.test(r) && t++, Math.min(4, t);
222
+ let a = 0;
223
+ return s.length >= 8 && a++, s.length >= 12 && a++, /[a-z]/.test(s) && /[A-Z]/.test(s) && a++, /\d/.test(s) && a++, /[^a-zA-Z0-9]/.test(s) && a++, Math.min(4, a);
219
224
  }
220
- const Z = j(
221
- ({ password: r, strength: t, showLabel: c = !0, labels: n = he, className: i }, h) => {
222
- const l = t ?? Y(r), s = ue[l], u = (l + 1) / 5 * 100;
223
- return /* @__PURE__ */ a("div", { ref: h, className: `nice-password-strength${i ? ` ${i}` : ""}`, children: [
224
- /* @__PURE__ */ e("div", { className: "nice-password-strength__bar", children: /* @__PURE__ */ e(
225
- "div",
225
+ const te = /* @__PURE__ */ Object.assign(
226
+ /* @__PURE__ */ K(
227
+ ({ password: s, strength: a, showLabel: n = !0, labels: t, className: i }, d) => {
228
+ const { t: l } = q(), c = a ?? ee(s), h = pe[c], x = (c + 1) / 5 * 100;
229
+ return /* @__PURE__ */ r("div", { ref: d, className: `nice-password-strength${i ? ` ${i}` : ""}`, children: [
230
+ /* @__PURE__ */ e("div", { className: "nice-password-strength__bar", children: /* @__PURE__ */ e(
231
+ "div",
232
+ {
233
+ className: "nice-password-strength__fill",
234
+ style: { width: `${x}%`, backgroundColor: h }
235
+ }
236
+ ) }),
237
+ n && /* @__PURE__ */ e("span", { className: "nice-password-strength__label", style: { color: h }, children: t ? t[c] : l(`passwordStrength.level.${c}`, ue[c]) })
238
+ ] });
239
+ }
240
+ ),
241
+ { displayName: "NicePasswordStrength" }
242
+ ), Ae = /* @__PURE__ */ Object.assign(
243
+ /* @__PURE__ */ K(
244
+ ({
245
+ onSubmit: s,
246
+ loading: a = !1,
247
+ error: n,
248
+ onLoginClick: t,
249
+ showPasswordStrength: i = !0,
250
+ minPasswordStrength: d = 2,
251
+ termsUrl: l,
252
+ privacyUrl: c,
253
+ title: h,
254
+ logo: x,
255
+ footer: f,
256
+ className: g,
257
+ style: S
258
+ }, y) => {
259
+ const { t: o } = q(), [w, m] = _(""), [p, b] = _(""), [N, I] = _(""), [k, T] = _(""), [$, O] = _(""), [v, E] = _(!1), L = ee(k), A = k === $, D = w && N && k && A && v && L >= d && !a, u = M(
260
+ (C) => {
261
+ C.preventDefault(), D && (s == null || s({ firstName: w, lastName: p, email: N, password: k, acceptTerms: v }));
262
+ },
263
+ [D, w, p, N, k, v, s]
264
+ );
265
+ return /* @__PURE__ */ r(
266
+ "form",
226
267
  {
227
- className: "nice-password-strength__fill",
228
- style: { width: `${u}%`, backgroundColor: s }
229
- }
230
- ) }),
231
- c && /* @__PURE__ */ e("span", { className: "nice-password-strength__label", style: { color: s }, children: n[l] })
232
- ] });
233
- }
234
- );
235
- Z.displayName = "NicePasswordStrength";
236
- const me = j(
237
- ({
238
- onSubmit: r,
239
- loading: t = !1,
240
- error: c,
241
- onLoginClick: n,
242
- showPasswordStrength: i = !0,
243
- minPasswordStrength: h = 2,
244
- termsUrl: l,
245
- privacyUrl: s,
246
- title: u = "Create Account",
247
- logo: S,
248
- footer: d,
249
- className: A,
250
- style: b
251
- }, k) => {
252
- const [_, F] = g(""), [o, p] = g(""), [f, M] = g(""), [w, C] = g(""), [T, E] = g(""), [N, I] = g(!1), L = Y(w), x = w === T, D = _ && f && w && x && N && L >= h && !t, m = $(
253
- (v) => {
254
- v.preventDefault(), D && (r == null || r({ firstName: _, lastName: o, email: f, password: w, acceptTerms: N }));
255
- },
256
- [D, _, o, f, w, N, r]
257
- );
258
- return /* @__PURE__ */ a(
259
- "form",
260
- {
261
- ref: k,
262
- className: `nice-register-form${A ? ` ${A}` : ""}`,
263
- style: b,
264
- onSubmit: m,
265
- noValidate: !0,
266
- children: [
267
- S && /* @__PURE__ */ e("div", { className: "nice-register-form__logo", children: S }),
268
- /* @__PURE__ */ e("h2", { className: "nice-register-form__title", children: u }),
269
- c && /* @__PURE__ */ e("div", { className: "nice-register-form__error", role: "alert", children: c }),
270
- /* @__PURE__ */ a("div", { className: "nice-register-form__row", children: [
271
- /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
272
- /* @__PURE__ */ e("label", { htmlFor: "nice-reg-first", children: "First name *" }),
268
+ ref: y,
269
+ className: `nice-register-form${g ? ` ${g}` : ""}`,
270
+ style: S,
271
+ onSubmit: u,
272
+ noValidate: !0,
273
+ children: [
274
+ x && /* @__PURE__ */ e("div", { className: "nice-register-form__logo", children: x }),
275
+ /* @__PURE__ */ e("h2", { className: "nice-register-form__title", children: h ?? o("registrationForm.title", "Create Account") }),
276
+ n && /* @__PURE__ */ e("div", { className: "nice-register-form__error", role: "alert", children: n }),
277
+ /* @__PURE__ */ r("div", { className: "nice-register-form__row", children: [
278
+ /* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
279
+ /* @__PURE__ */ e("label", { htmlFor: "nice-reg-first", children: o("registrationForm.firstName", "First name *") }),
280
+ /* @__PURE__ */ e(
281
+ "input",
282
+ {
283
+ id: "nice-reg-first",
284
+ className: "nice-input",
285
+ type: "text",
286
+ value: w,
287
+ onChange: (C) => m(C.target.value),
288
+ required: !0,
289
+ disabled: a,
290
+ autoComplete: "given-name"
291
+ }
292
+ )
293
+ ] }),
294
+ /* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
295
+ /* @__PURE__ */ e("label", { htmlFor: "nice-reg-last", children: o("registrationForm.lastName", "Last name") }),
296
+ /* @__PURE__ */ e(
297
+ "input",
298
+ {
299
+ id: "nice-reg-last",
300
+ className: "nice-input",
301
+ type: "text",
302
+ value: p,
303
+ onChange: (C) => b(C.target.value),
304
+ disabled: a,
305
+ autoComplete: "family-name"
306
+ }
307
+ )
308
+ ] })
309
+ ] }),
310
+ /* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
311
+ /* @__PURE__ */ e("label", { htmlFor: "nice-reg-email", children: o("registrationForm.email", "Email *") }),
273
312
  /* @__PURE__ */ e(
274
313
  "input",
275
314
  {
276
- id: "nice-reg-first",
315
+ id: "nice-reg-email",
277
316
  className: "nice-input",
278
- type: "text",
279
- value: _,
280
- onChange: (v) => F(v.target.value),
317
+ type: "email",
318
+ value: N,
319
+ onChange: (C) => I(C.target.value),
281
320
  required: !0,
282
- disabled: t,
283
- autoComplete: "given-name"
321
+ disabled: a,
322
+ autoComplete: "email"
284
323
  }
285
324
  )
286
325
  ] }),
287
- /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
288
- /* @__PURE__ */ e("label", { htmlFor: "nice-reg-last", children: "Last name" }),
326
+ /* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
327
+ /* @__PURE__ */ e("label", { htmlFor: "nice-reg-pass", children: o("registrationForm.password", "Password *") }),
289
328
  /* @__PURE__ */ e(
290
329
  "input",
291
330
  {
292
- id: "nice-reg-last",
331
+ id: "nice-reg-pass",
293
332
  className: "nice-input",
294
- type: "text",
295
- value: o,
296
- onChange: (v) => p(v.target.value),
297
- disabled: t,
298
- autoComplete: "family-name"
333
+ type: "password",
334
+ value: k,
335
+ onChange: (C) => T(C.target.value),
336
+ required: !0,
337
+ disabled: a,
338
+ autoComplete: "new-password"
299
339
  }
300
- )
301
- ] })
302
- ] }),
303
- /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
304
- /* @__PURE__ */ e("label", { htmlFor: "nice-reg-email", children: "Email *" }),
305
- /* @__PURE__ */ e(
306
- "input",
307
- {
308
- id: "nice-reg-email",
309
- className: "nice-input",
310
- type: "email",
311
- value: f,
312
- onChange: (v) => M(v.target.value),
313
- required: !0,
314
- disabled: t,
315
- autoComplete: "email"
316
- }
317
- )
318
- ] }),
319
- /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
320
- /* @__PURE__ */ e("label", { htmlFor: "nice-reg-pass", children: "Password *" }),
321
- /* @__PURE__ */ e(
322
- "input",
323
- {
324
- id: "nice-reg-pass",
325
- className: "nice-input",
326
- type: "password",
327
- value: w,
328
- onChange: (v) => C(v.target.value),
329
- required: !0,
330
- disabled: t,
331
- autoComplete: "new-password"
332
- }
333
- ),
334
- i && w.length > 0 && /* @__PURE__ */ e(Z, { password: w })
335
- ] }),
336
- /* @__PURE__ */ a("div", { className: "nice-register-form__field", children: [
337
- /* @__PURE__ */ e("label", { htmlFor: "nice-reg-confirm", children: "Confirm password *" }),
338
- /* @__PURE__ */ e(
339
- "input",
340
- {
341
- id: "nice-reg-confirm",
342
- className: "nice-input",
343
- type: "password",
344
- value: T,
345
- onChange: (v) => E(v.target.value),
346
- required: !0,
347
- disabled: t,
348
- autoComplete: "new-password"
349
- }
350
- ),
351
- T && !x && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
352
- ] }),
353
- /* @__PURE__ */ a("label", { className: "nice-register-form__terms", children: [
340
+ ),
341
+ i && k.length > 0 && /* @__PURE__ */ e(te, { password: k })
342
+ ] }),
343
+ /* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
344
+ /* @__PURE__ */ e("label", { htmlFor: "nice-reg-confirm", children: o("registrationForm.confirmPassword", "Confirm password *") }),
345
+ /* @__PURE__ */ e(
346
+ "input",
347
+ {
348
+ id: "nice-reg-confirm",
349
+ className: "nice-input",
350
+ type: "password",
351
+ value: $,
352
+ onChange: (C) => O(C.target.value),
353
+ required: !0,
354
+ disabled: a,
355
+ autoComplete: "new-password"
356
+ }
357
+ ),
358
+ $ && !A && /* @__PURE__ */ e("span", { className: "nice-error-text", children: o("registrationForm.passwordsDoNotMatch", "Passwords do not match") })
359
+ ] }),
360
+ /* @__PURE__ */ r("label", { className: "nice-register-form__terms", children: [
361
+ /* @__PURE__ */ e(
362
+ "input",
363
+ {
364
+ type: "checkbox",
365
+ checked: v,
366
+ onChange: (C) => E(C.target.checked),
367
+ disabled: a
368
+ }
369
+ ),
370
+ /* @__PURE__ */ r("span", { children: [
371
+ o("registrationForm.iAcceptThe", "I accept the"),
372
+ " ",
373
+ l ? /* @__PURE__ */ e("a", { href: l, target: "_blank", rel: "noopener noreferrer", children: o("registrationForm.terms", "Terms") }) : o("registrationForm.terms", "Terms"),
374
+ c && /* @__PURE__ */ r(ce, { children: [
375
+ " ",
376
+ o("registrationForm.and", "and"),
377
+ " ",
378
+ /* @__PURE__ */ e("a", { href: c, target: "_blank", rel: "noopener noreferrer", children: o("registrationForm.privacyPolicy", "Privacy Policy") })
379
+ ] }),
380
+ " *"
381
+ ] })
382
+ ] }),
354
383
  /* @__PURE__ */ e(
355
- "input",
384
+ "button",
356
385
  {
357
- type: "checkbox",
358
- checked: N,
359
- onChange: (v) => I(v.target.checked),
360
- disabled: t
386
+ type: "submit",
387
+ className: "nice-btn nice-btn--primary nice-register-form__submit",
388
+ disabled: !D,
389
+ children: a ? "…" : o("registrationForm.register", "Register")
361
390
  }
362
391
  ),
363
- /* @__PURE__ */ a("span", { children: [
364
- "I accept the",
365
- " ",
366
- l ? /* @__PURE__ */ e("a", { href: l, target: "_blank", rel: "noopener noreferrer", children: "Terms" }) : "Terms",
367
- s && /* @__PURE__ */ a(ae, { children: [
368
- " ",
369
- "and",
370
- " ",
371
- /* @__PURE__ */ e("a", { href: s, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" })
392
+ t && /* @__PURE__ */ r("div", { className: "nice-register-form__login", children: [
393
+ /* @__PURE__ */ r("span", { children: [
394
+ o("registrationForm.alreadyHaveAnAccount", "Already have an account?"),
395
+ " "
372
396
  ] }),
373
- " *"
374
- ] })
375
- ] }),
376
- /* @__PURE__ */ e(
377
- "button",
378
- {
379
- type: "submit",
380
- className: "nice-btn nice-btn--primary nice-register-form__submit",
381
- disabled: !D,
382
- children: t ? "…" : "Register"
383
- }
384
- ),
385
- n && /* @__PURE__ */ a("div", { className: "nice-register-form__login", children: [
386
- /* @__PURE__ */ e("span", { children: "Already have an account? " }),
387
- /* @__PURE__ */ e("button", { type: "button", onClick: n, children: "Sign in" })
388
- ] }),
389
- d && /* @__PURE__ */ e("div", { className: "nice-register-form__footer", children: d })
390
- ]
391
- }
392
- );
393
- }
394
- );
395
- me.displayName = "NiceRegistrationForm";
396
- const pe = ({ style: r }) => /* @__PURE__ */ e(
397
+ /* @__PURE__ */ e("button", { type: "button", onClick: t, children: o("registrationForm.signIn", "Sign in") })
398
+ ] }),
399
+ f && /* @__PURE__ */ e("div", { className: "nice-register-form__footer", children: f })
400
+ ]
401
+ }
402
+ );
403
+ }
404
+ ),
405
+ { displayName: "NiceRegistrationForm" }
406
+ ), ge = ({ style: s }) => /* @__PURE__ */ e(
397
407
  "span",
398
408
  {
399
409
  "aria-hidden": "true",
@@ -405,10 +415,10 @@ const pe = ({ style: r }) => /* @__PURE__ */ e(
405
415
  borderRight: "0.12em solid currentColor",
406
416
  borderBottom: "0.12em solid currentColor",
407
417
  transform: "rotate(45deg)",
408
- ...r
418
+ ...s
409
419
  }
410
420
  }
411
- ), re = ({ style: r }) => /* @__PURE__ */ e(
421
+ ), ie = ({ style: s }) => /* @__PURE__ */ e(
412
422
  "span",
413
423
  {
414
424
  "aria-hidden": "true",
@@ -420,22 +430,22 @@ const pe = ({ style: r }) => /* @__PURE__ */ e(
420
430
  border: "0.12em solid currentColor",
421
431
  borderTopColor: "transparent",
422
432
  transform: "rotate(-45deg)",
423
- ...r
433
+ ...s
424
434
  }
425
435
  }
426
- ), ee = {
436
+ ), ae = {
427
437
  lowercase: "abcdefghijklmnopqrstuvwxyz",
428
438
  uppercase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
429
439
  digits: "0123456789",
430
440
  symbols: "!@#$%^&*()-_=+[]{};:,.?/~"
431
- }, fe = /[0Oo1lI|]/g, W = {
441
+ }, fe = /[0Oo1lI|]/g, J = {
432
442
  length: 16,
433
443
  lowercase: !0,
434
444
  uppercase: !0,
435
445
  digits: !0,
436
446
  symbols: !0,
437
447
  excludeAmbiguous: !1
438
- }, ge = {
448
+ }, ne = {
439
449
  password: "Generated password",
440
450
  length: "Length",
441
451
  lowercase: "Lowercase (a–z)",
@@ -447,92 +457,100 @@ const pe = ({ style: r }) => /* @__PURE__ */ e(
447
457
  copy: "Copy",
448
458
  copied: "Copied",
449
459
  noCharacterSets: "Pick at least one kind of character."
450
- }, be = (r) => {
451
- const t = globalThis.crypto;
452
- if (!t || typeof t.getRandomValues != "function")
460
+ }, be = (s) => {
461
+ const a = globalThis.crypto;
462
+ if (!a || typeof a.getRandomValues != "function")
453
463
  throw new Error("generatePassword: crypto.getRandomValues is not available");
454
- return t.getRandomValues(r);
464
+ return a.getRandomValues(s);
455
465
  };
456
466
  let _e = 0;
457
- function X(r, t) {
458
- const c = Math.floor(4294967296 / r) * r, n = new Uint32Array(1);
467
+ function X(s, a) {
468
+ const n = Math.floor(4294967296 / s) * s, t = new Uint32Array(1);
459
469
  for (; ; ) {
460
- const i = t(n)[0];
461
- if (i < c)
462
- return i % r;
470
+ const i = a(t)[0];
471
+ if (i < n)
472
+ return i % s;
463
473
  }
464
474
  }
465
- function te(r = {}, t = be) {
466
- const c = { ...W, ...r }, n = ["lowercase", "uppercase", "digits", "symbols"].filter((s) => c[s]).map((s) => c.excludeAmbiguous ? ee[s].replace(fe, "") : ee[s]).filter((s) => s.length > 0);
467
- if (n.length === 0)
475
+ function re(s = {}, a = be) {
476
+ const n = { ...J, ...s }, t = ["lowercase", "uppercase", "digits", "symbols"].filter((c) => n[c]).map((c) => n.excludeAmbiguous ? ae[c].replace(fe, "") : ae[c]).filter((c) => c.length > 0);
477
+ if (t.length === 0)
468
478
  return "";
469
- const i = Math.max(n.length, Math.min(1024, Math.floor(c.length))), h = n.join(""), l = n.map((s) => s[X(s.length, t)]);
479
+ const i = Math.max(t.length, Math.min(1024, Math.floor(n.length))), d = t.join(""), l = t.map((c) => c[X(c.length, a)]);
470
480
  for (; l.length < i; )
471
- l.push(h[X(h.length, t)]);
472
- for (let s = l.length - 1; s > 0; s--) {
473
- const u = X(s + 1, t);
474
- [l[s], l[u]] = [l[u], l[s]];
481
+ l.push(d[X(d.length, a)]);
482
+ for (let c = l.length - 1; c > 0; c--) {
483
+ const h = X(c + 1, a);
484
+ [l[c], l[h]] = [l[h], l[c]];
475
485
  }
476
486
  return l.join("");
477
487
  }
478
- const Fe = ({
479
- value: r,
480
- defaultValue: t = "",
481
- onChange: c,
482
- options: n,
488
+ const Me = ({
489
+ value: s,
490
+ defaultValue: a = "",
491
+ onChange: n,
492
+ options: t,
483
493
  defaultOptions: i,
484
- onOptionsChange: h,
494
+ onOptionsChange: d,
485
495
  minLength: l = 8,
486
- maxLength: s = 64,
487
- showStrength: u = !0,
488
- showCopy: S = !0,
489
- onCopy: d,
490
- labels: A,
491
- disabled: b = !1,
492
- className: k,
493
- style: _,
494
- id: F
496
+ maxLength: c = 64,
497
+ showStrength: h = !0,
498
+ showCopy: x = !0,
499
+ onCopy: f,
500
+ labels: g,
501
+ disabled: S = !1,
502
+ className: y,
503
+ style: o,
504
+ id: w
495
505
  }) => {
496
- const o = { ...ge, ...A }, [p] = g(() => `nice-password-generator-${++_e}`), f = F ?? p, [M, w] = g(() => ({
497
- ...W,
506
+ const { t: m } = q(), p = {
507
+ ...Object.fromEntries(
508
+ Object.keys(ne).map((R) => [
509
+ R,
510
+ m(`passwordGenerator.${R}`, ne[R])
511
+ ])
512
+ ),
513
+ ...g
514
+ }, [b] = _(() => `nice-password-generator-${++_e}`), N = w ?? b, [I, k] = _(() => ({
515
+ ...J,
498
516
  ...i
499
- })), C = n ? { ...W, ...n } : M, [T, E] = g(
500
- () => r === void 0 && !t ? te({ ...W, ...i, ...n }) : t
501
- ), N = r ?? T, [I, L] = g(!1), x = H(void 0);
502
- Q(() => () => clearTimeout(x.current), []);
503
- const D = $(
504
- (P) => {
505
- r === void 0 && E(P), L(!1), c == null || c(P);
517
+ })), T = t ? { ...J, ...t } : I, [$, O] = _(
518
+ () => s === void 0 && !a ? re({ ...J, ...i, ...t }) : a
519
+ ), v = s ?? $, [E, L] = _(!1), A = Q(void 0);
520
+ Z(() => () => clearTimeout(A.current), []);
521
+ const D = M(
522
+ (R) => {
523
+ s === void 0 && O(R), L(!1), n == null || n(R);
506
524
  },
507
- [r, c]
508
- ), m = $(
509
- (P) => D(te(P)),
525
+ [s, n]
526
+ ), u = M(
527
+ (R) => D(re(R)),
510
528
  [D]
511
- ), v = (P, O) => {
512
- const q = { ...C, [P]: O };
513
- n || w(q), h == null || h(q), m(q);
514
- }, z = async () => {
515
- !N || !navigator.clipboard || (await navigator.clipboard.writeText(N), L(!0), clearTimeout(x.current), x.current = setTimeout(() => L(!1), 1500), d == null || d(N));
516
- }, R = !C.lowercase && !C.uppercase && !C.digits && !C.symbols, U = Math.min(s, Math.max(l, C.length));
517
- return /* @__PURE__ */ a(
529
+ ), C = (R, j) => {
530
+ const z = { ...T, [R]: j };
531
+ t || k(z), d == null || d(z), u(z);
532
+ }, H = async () => {
533
+ !v || !navigator.clipboard || (await navigator.clipboard.writeText(v), L(!0), clearTimeout(A.current), A.current = setTimeout(() => L(!1), 1500), f == null || f(v));
534
+ }, P = !T.lowercase && !T.uppercase && !T.digits && !T.symbols, U = Math.min(c, Math.max(l, T.length));
535
+ return /* @__PURE__ */ r(
518
536
  "div",
519
537
  {
520
- id: F,
521
- className: `nice-password-generator${k ? ` ${k}` : ""}`,
522
- style: _,
538
+ id: w,
539
+ className: `nice-password-generator${y ? ` ${y}` : ""}`,
540
+ style: o,
523
541
  children: [
524
- /* @__PURE__ */ a("div", { className: "nice-password-generator__output", children: [
542
+ /* @__PURE__ */ r("div", { className: "nice-password-generator__output", children: [
525
543
  /* @__PURE__ */ e(
526
544
  "input",
527
545
  {
528
- id: `${f}-value`,
546
+ id: `${N}-value`,
529
547
  className: "nice-password-generator__value",
530
548
  type: "text",
531
549
  readOnly: !0,
532
550
  spellCheck: !1,
533
551
  autoComplete: "off",
534
- value: N,
535
- "aria-label": o.password
552
+ value: v,
553
+ "aria-label": p.password
536
554
  }
537
555
  ),
538
556
  /* @__PURE__ */ e(
@@ -540,749 +558,790 @@ const Fe = ({
540
558
  {
541
559
  type: "button",
542
560
  className: "nice-password-generator__button",
543
- onClick: () => m(C),
544
- disabled: b || R,
545
- "aria-label": o.generate,
546
- title: o.generate,
547
- children: /* @__PURE__ */ e(re, {})
561
+ onClick: () => u(T),
562
+ disabled: S || P,
563
+ "aria-label": p.generate,
564
+ title: p.generate,
565
+ children: /* @__PURE__ */ e(ie, {})
548
566
  }
549
567
  ),
550
- S && /* @__PURE__ */ e(
568
+ x && /* @__PURE__ */ e(
551
569
  "button",
552
570
  {
553
571
  type: "button",
554
572
  className: "nice-password-generator__button nice-password-generator__button--copy",
555
- onClick: z,
556
- disabled: b || !N,
573
+ onClick: H,
574
+ disabled: S || !v,
557
575
  "aria-live": "polite",
558
- children: I ? /* @__PURE__ */ a(ae, { children: [
559
- /* @__PURE__ */ e(pe, {}),
576
+ children: E ? /* @__PURE__ */ r(ce, { children: [
577
+ /* @__PURE__ */ e(ge, {}),
560
578
  " ",
561
- o.copied
562
- ] }) : o.copy
579
+ p.copied
580
+ ] }) : p.copy
563
581
  }
564
582
  )
565
583
  ] }),
566
- u && /* @__PURE__ */ e(Z, { password: N }),
567
- /* @__PURE__ */ a("div", { className: "nice-password-generator__length", children: [
568
- /* @__PURE__ */ e("label", { htmlFor: `${f}-length`, children: o.length }),
584
+ h && /* @__PURE__ */ e(te, { password: v }),
585
+ /* @__PURE__ */ r("div", { className: "nice-password-generator__length", children: [
586
+ /* @__PURE__ */ e("label", { htmlFor: `${N}-length`, children: p.length }),
569
587
  /* @__PURE__ */ e(
570
588
  "input",
571
589
  {
572
- id: `${f}-length`,
590
+ id: `${N}-length`,
573
591
  type: "range",
574
592
  min: l,
575
- max: s,
593
+ max: c,
576
594
  value: U,
577
- disabled: b,
578
- onChange: (P) => v("length", Number(P.target.value))
595
+ disabled: S,
596
+ onChange: (R) => C("length", Number(R.target.value))
579
597
  }
580
598
  ),
581
- /* @__PURE__ */ e("output", { htmlFor: `${f}-length`, className: "nice-password-generator__length-value", children: U })
599
+ /* @__PURE__ */ e("output", { htmlFor: `${N}-length`, className: "nice-password-generator__length-value", children: U })
582
600
  ] }),
583
601
  /* @__PURE__ */ e("div", { className: "nice-password-generator__sets", children: ["lowercase", "uppercase", "digits", "symbols", "excludeAmbiguous"].map(
584
- (P) => /* @__PURE__ */ a("label", { className: "nice-password-generator__option", children: [
602
+ (R) => /* @__PURE__ */ r("label", { className: "nice-password-generator__option", children: [
585
603
  /* @__PURE__ */ e(
586
604
  "input",
587
605
  {
588
606
  type: "checkbox",
589
- checked: C[P],
590
- disabled: b,
591
- onChange: (O) => v(P, O.target.checked)
607
+ checked: T[R],
608
+ disabled: S,
609
+ onChange: (j) => C(R, j.target.checked)
592
610
  }
593
611
  ),
594
- o[P]
595
- ] }, P)
612
+ p[R]
613
+ ] }, R)
596
614
  ) }),
597
- R && /* @__PURE__ */ e("p", { className: "nice-password-generator__error", role: "alert", children: o.noCharacterSets })
615
+ P && /* @__PURE__ */ e("p", { className: "nice-password-generator__error", role: "alert", children: p.noCharacterSets })
598
616
  ]
599
617
  }
600
618
  );
601
- }, Ne = j(
602
- ({
603
- requireCurrentPassword: r = !0,
604
- onSubmit: t,
605
- loading: c = !1,
606
- error: n,
607
- success: i,
608
- minPasswordStrength: h = 2,
609
- title: l = "Change Password",
610
- className: s,
611
- style: u
612
- }, S) => {
613
- const [d, A] = g(""), [b, k] = g(""), [_, F] = g(""), o = Y(b), p = b === _, f = (!r || d.length > 0) && b.length > 0 && p && o >= h && !c, M = $(
614
- (w) => {
615
- w.preventDefault(), f && (t == null || t({
616
- currentPassword: r ? d : void 0,
617
- newPassword: b
618
- }));
619
- },
620
- [f, d, b, r, t]
621
- );
622
- return /* @__PURE__ */ a(
623
- "form",
624
- {
625
- ref: S,
626
- className: `nice-change-password${s ? ` ${s}` : ""}`,
627
- style: u,
628
- onSubmit: M,
629
- noValidate: !0,
630
- children: [
631
- /* @__PURE__ */ e("h3", { className: "nice-change-password__title", children: l }),
632
- n && /* @__PURE__ */ e("div", { className: "nice-change-password__error", role: "alert", children: n }),
633
- i && /* @__PURE__ */ e("div", { className: "nice-change-password__success", role: "status", children: i }),
634
- r && /* @__PURE__ */ a("div", { className: "nice-change-password__field", children: [
635
- /* @__PURE__ */ e("label", { htmlFor: "nice-cp-current", children: "Current password" }),
636
- /* @__PURE__ */ e(
637
- "input",
638
- {
639
- id: "nice-cp-current",
640
- className: "nice-input",
641
- type: "password",
642
- value: d,
643
- onChange: (w) => A(w.target.value),
644
- autoComplete: "current-password",
645
- disabled: c,
646
- required: !0
647
- }
648
- )
649
- ] }),
650
- /* @__PURE__ */ a("div", { className: "nice-change-password__field", children: [
651
- /* @__PURE__ */ e("label", { htmlFor: "nice-cp-new", children: "New password" }),
652
- /* @__PURE__ */ e(
653
- "input",
654
- {
655
- id: "nice-cp-new",
656
- className: "nice-input",
657
- type: "password",
658
- value: b,
659
- onChange: (w) => k(w.target.value),
660
- autoComplete: "new-password",
661
- disabled: c,
662
- required: !0
663
- }
664
- ),
665
- b.length > 0 && /* @__PURE__ */ e(Z, { password: b })
666
- ] }),
667
- /* @__PURE__ */ a("div", { className: "nice-change-password__field", children: [
668
- /* @__PURE__ */ e("label", { htmlFor: "nice-cp-confirm", children: "Confirm new password" }),
669
- /* @__PURE__ */ e(
670
- "input",
671
- {
672
- id: "nice-cp-confirm",
673
- className: "nice-input",
674
- type: "password",
675
- value: _,
676
- onChange: (w) => F(w.target.value),
677
- autoComplete: "new-password",
678
- disabled: c,
679
- required: !0
680
- }
681
- ),
682
- _ && !p && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
683
- ] }),
684
- /* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !f, children: c ? "…" : "Change Password" })
685
- ]
686
- }
687
- );
688
- }
689
- );
690
- Ne.displayName = "NiceChangePassword";
691
- const we = j(
692
- ({
693
- secret: r,
694
- qrCodeUrl: t,
695
- issuer: c,
696
- accountName: n,
697
- onVerify: i,
698
- loading: h = !1,
699
- error: l,
700
- onCancel: s,
701
- recoveryCodes: u,
702
- step: S = "setup",
703
- onStepChange: d,
704
- className: A,
705
- style: b
706
- }, k) => {
707
- const [_, F] = g(""), [o, p] = g(!1), [f, M] = g(!1), w = $(
708
- (T) => {
709
- T.preventDefault(), _.length >= 6 && (i == null || i(_));
710
- },
711
- [_, i]
712
- ), C = `otpauth://totp/${c ? `${c}:` : ""}${n ?? "user"}?secret=${r}${c ? `&issuer=${c}` : ""}&digits=6&period=30`;
713
- return /* @__PURE__ */ a("div", { ref: k, className: `nice-2fa-setup${A ? ` ${A}` : ""}`, style: b, children: [
714
- /* @__PURE__ */ e("h3", { className: "nice-2fa-setup__title", children: "Two-Factor Authentication" }),
715
- S === "setup" && /* @__PURE__ */ a("div", { className: "nice-2fa-setup__step", children: [
716
- /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.):" }),
717
- t ? /* @__PURE__ */ e("img", { src: t, alt: "2FA QR Code", className: "nice-2fa-setup__qr" }) : /* @__PURE__ */ a("div", { className: "nice-2fa-setup__qr-placeholder", children: [
718
- /* @__PURE__ */ e("span", { children: "QR Code" }),
719
- /* @__PURE__ */ e("code", { className: "nice-2fa-setup__uri", children: C })
720
- ] }),
721
- /* @__PURE__ */ a("div", { className: "nice-2fa-setup__secret", children: [
722
- /* @__PURE__ */ e("span", { children: "Or enter manually: " }),
723
- o ? /* @__PURE__ */ e("code", { className: "nice-2fa-setup__secret-key", children: r }) : /* @__PURE__ */ e("button", { type: "button", onClick: () => p(!0), children: "Show secret key" })
724
- ] }),
725
- /* @__PURE__ */ e(
726
- "button",
727
- {
728
- type: "button",
729
- className: "nice-btn nice-btn--primary",
730
- onClick: () => d == null ? void 0 : d("verify"),
731
- children: "Next — Verify"
732
- }
733
- )
734
- ] }),
735
- S === "verify" && /* @__PURE__ */ a("form", { className: "nice-2fa-setup__step", onSubmit: w, children: [
736
- /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Enter the 6-digit code from your authenticator app:" }),
737
- l && /* @__PURE__ */ e("div", { className: "nice-2fa-setup__error", role: "alert", children: l }),
738
- /* @__PURE__ */ e(
739
- "input",
740
- {
741
- className: "nice-input nice-2fa-setup__code-input",
742
- type: "text",
743
- inputMode: "numeric",
744
- maxLength: 6,
745
- value: _,
746
- onChange: (T) => F(T.target.value.replace(/\D/g, "").slice(0, 6)),
747
- placeholder: "000000",
748
- autoFocus: !0,
749
- disabled: h,
750
- autoComplete: "one-time-code"
751
- }
752
- ),
753
- /* @__PURE__ */ a("div", { className: "nice-2fa-setup__actions", children: [
754
- /* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () => d == null ? void 0 : d("setup"), children: "Back" }),
755
- /* @__PURE__ */ e(
756
- "button",
757
- {
758
- type: "submit",
759
- className: "nice-btn nice-btn--primary",
760
- disabled: h || _.length < 6,
761
- children: h ? "…" : "Verify"
762
- }
763
- )
764
- ] })
765
- ] }),
766
- S === "recovery" && u && /* @__PURE__ */ a("div", { className: "nice-2fa-setup__step", children: [
767
- /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Save these recovery codes in a safe place. Each code can only be used once:" }),
768
- /* @__PURE__ */ e("div", { className: "nice-2fa-setup__recovery-codes", children: u.map((T, E) => /* @__PURE__ */ e("code", { className: "nice-2fa-setup__recovery-code", children: T }, E)) }),
769
- /* @__PURE__ */ e(
770
- "button",
771
- {
772
- type: "button",
773
- className: "nice-btn",
774
- onClick: () => {
775
- var T;
776
- (T = navigator.clipboard) == null || T.writeText(u.join(`
777
- `)), M(!0);
778
- },
779
- children: f ? "Copied!" : "Copy all codes"
780
- }
781
- ),
782
- s && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: s, children: "Done" })
783
- ] }),
784
- s && S !== "recovery" && /* @__PURE__ */ e("button", { type: "button", className: "nice-2fa-setup__cancel", onClick: s, children: "Cancel" })
785
- ] });
786
- }
787
- );
788
- we.displayName = "NiceTwoFaSetup";
789
- const ve = 500;
790
- function V(r, t) {
791
- return Math.floor(Math.random() * (t - r + 1)) + r;
619
+ }, $e = /* @__PURE__ */ Object.assign(
620
+ /* @__PURE__ */ K(
621
+ ({
622
+ requireCurrentPassword: s = !0,
623
+ onSubmit: a,
624
+ loading: n = !1,
625
+ error: t,
626
+ success: i,
627
+ minPasswordStrength: d = 2,
628
+ title: l,
629
+ className: c,
630
+ style: h
631
+ }, x) => {
632
+ const { t: f } = q(), [g, S] = _(""), [y, o] = _(""), [w, m] = _(""), p = ee(y), b = y === w, N = (!s || g.length > 0) && y.length > 0 && b && p >= d && !n, I = M(
633
+ (k) => {
634
+ k.preventDefault(), N && (a == null || a({
635
+ currentPassword: s ? g : void 0,
636
+ newPassword: y
637
+ }));
638
+ },
639
+ [N, g, y, s, a]
640
+ );
641
+ return /* @__PURE__ */ r(
642
+ "form",
643
+ {
644
+ ref: x,
645
+ className: `nice-change-password${c ? ` ${c}` : ""}`,
646
+ style: h,
647
+ onSubmit: I,
648
+ noValidate: !0,
649
+ children: [
650
+ /* @__PURE__ */ e("h3", { className: "nice-change-password__title", children: l ?? f("changePassword.title", "Change Password") }),
651
+ t && /* @__PURE__ */ e("div", { className: "nice-change-password__error", role: "alert", children: t }),
652
+ i && /* @__PURE__ */ e("div", { className: "nice-change-password__success", role: "status", children: i }),
653
+ s && /* @__PURE__ */ r("div", { className: "nice-change-password__field", children: [
654
+ /* @__PURE__ */ e("label", { htmlFor: "nice-cp-current", children: f("changePassword.currentPassword", "Current password") }),
655
+ /* @__PURE__ */ e(
656
+ "input",
657
+ {
658
+ id: "nice-cp-current",
659
+ className: "nice-input",
660
+ type: "password",
661
+ value: g,
662
+ onChange: (k) => S(k.target.value),
663
+ autoComplete: "current-password",
664
+ disabled: n,
665
+ required: !0
666
+ }
667
+ )
668
+ ] }),
669
+ /* @__PURE__ */ r("div", { className: "nice-change-password__field", children: [
670
+ /* @__PURE__ */ e("label", { htmlFor: "nice-cp-new", children: f("changePassword.newPassword", "New password") }),
671
+ /* @__PURE__ */ e(
672
+ "input",
673
+ {
674
+ id: "nice-cp-new",
675
+ className: "nice-input",
676
+ type: "password",
677
+ value: y,
678
+ onChange: (k) => o(k.target.value),
679
+ autoComplete: "new-password",
680
+ disabled: n,
681
+ required: !0
682
+ }
683
+ ),
684
+ y.length > 0 && /* @__PURE__ */ e(te, { password: y })
685
+ ] }),
686
+ /* @__PURE__ */ r("div", { className: "nice-change-password__field", children: [
687
+ /* @__PURE__ */ e("label", { htmlFor: "nice-cp-confirm", children: f("changePassword.confirmNewPassword", "Confirm new password") }),
688
+ /* @__PURE__ */ e(
689
+ "input",
690
+ {
691
+ id: "nice-cp-confirm",
692
+ className: "nice-input",
693
+ type: "password",
694
+ value: w,
695
+ onChange: (k) => m(k.target.value),
696
+ autoComplete: "new-password",
697
+ disabled: n,
698
+ required: !0
699
+ }
700
+ ),
701
+ w && !b && /* @__PURE__ */ e("span", { className: "nice-error-text", children: f("changePassword.passwordsDoNotMatch", "Passwords do not match") })
702
+ ] }),
703
+ /* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !N, children: n ? "…" : f("changePassword.changePassword", "Change Password") })
704
+ ]
705
+ }
706
+ );
707
+ }
708
+ ),
709
+ { displayName: "NiceChangePassword" }
710
+ ), Pe = /* @__PURE__ */ Object.assign(
711
+ /* @__PURE__ */ K(
712
+ ({
713
+ secret: s,
714
+ qrCodeUrl: a,
715
+ issuer: n,
716
+ accountName: t,
717
+ onVerify: i,
718
+ loading: d = !1,
719
+ error: l,
720
+ onCancel: c,
721
+ recoveryCodes: h,
722
+ step: x = "setup",
723
+ onStepChange: f,
724
+ className: g,
725
+ style: S
726
+ }, y) => {
727
+ const { t: o } = q(), [w, m] = _(""), [p, b] = _(!1), [N, I] = _(!1), k = M(
728
+ ($) => {
729
+ $.preventDefault(), w.length >= 6 && (i == null || i(w));
730
+ },
731
+ [w, i]
732
+ ), T = `otpauth://totp/${n ? `${n}:` : ""}${t ?? "user"}?secret=${s}${n ? `&issuer=${n}` : ""}&digits=6&period=30`;
733
+ return /* @__PURE__ */ r(
734
+ "div",
735
+ {
736
+ ref: y,
737
+ className: `nice-2fa-setup${g ? ` ${g}` : ""}`,
738
+ style: S,
739
+ children: [
740
+ /* @__PURE__ */ e("h3", { className: "nice-2fa-setup__title", children: o("twoFaSetup.twoFactorAuthentication", "Two-Factor Authentication") }),
741
+ x === "setup" && /* @__PURE__ */ r("div", { className: "nice-2fa-setup__step", children: [
742
+ /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: o(
743
+ "twoFaSetup.scanThisQrCodeWith",
744
+ "Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.):"
745
+ ) }),
746
+ a ? /* @__PURE__ */ e(
747
+ "img",
748
+ {
749
+ src: a,
750
+ alt: o("twoFaSetup.n2faQrCode", "2FA QR Code"),
751
+ className: "nice-2fa-setup__qr"
752
+ }
753
+ ) : /* @__PURE__ */ r("div", { className: "nice-2fa-setup__qr-placeholder", children: [
754
+ /* @__PURE__ */ e("span", { children: o("twoFaSetup.qrCode", "QR Code") }),
755
+ /* @__PURE__ */ e("code", { className: "nice-2fa-setup__uri", children: T })
756
+ ] }),
757
+ /* @__PURE__ */ r("div", { className: "nice-2fa-setup__secret", children: [
758
+ /* @__PURE__ */ r("span", { children: [
759
+ o("twoFaSetup.orEnterManually", "Or enter manually:"),
760
+ " "
761
+ ] }),
762
+ p ? /* @__PURE__ */ e("code", { className: "nice-2fa-setup__secret-key", children: s }) : /* @__PURE__ */ e("button", { type: "button", onClick: () => b(!0), children: o("twoFaSetup.showSecretKey", "Show secret key") })
763
+ ] }),
764
+ /* @__PURE__ */ e(
765
+ "button",
766
+ {
767
+ type: "button",
768
+ className: "nice-btn nice-btn--primary",
769
+ onClick: () => f == null ? void 0 : f("verify"),
770
+ children: o("twoFaSetup.nextVerify", "Next — Verify")
771
+ }
772
+ )
773
+ ] }),
774
+ x === "verify" && /* @__PURE__ */ r("form", { className: "nice-2fa-setup__step", onSubmit: k, children: [
775
+ /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: o(
776
+ "twoFaSetup.enterThe6DigitCode",
777
+ "Enter the 6-digit code from your authenticator app:"
778
+ ) }),
779
+ l && /* @__PURE__ */ e("div", { className: "nice-2fa-setup__error", role: "alert", children: l }),
780
+ /* @__PURE__ */ e(
781
+ "input",
782
+ {
783
+ className: "nice-input nice-2fa-setup__code-input",
784
+ type: "text",
785
+ inputMode: "numeric",
786
+ maxLength: 6,
787
+ value: w,
788
+ onChange: ($) => m($.target.value.replace(/\D/g, "").slice(0, 6)),
789
+ placeholder: "000000",
790
+ autoFocus: !0,
791
+ disabled: d,
792
+ autoComplete: "one-time-code"
793
+ }
794
+ ),
795
+ /* @__PURE__ */ r("div", { className: "nice-2fa-setup__actions", children: [
796
+ /* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () => f == null ? void 0 : f("setup"), children: o("twoFaSetup.back", "Back") }),
797
+ /* @__PURE__ */ e(
798
+ "button",
799
+ {
800
+ type: "submit",
801
+ className: "nice-btn nice-btn--primary",
802
+ disabled: d || w.length < 6,
803
+ children: d ? "…" : o("twoFaSetup.verify", "Verify")
804
+ }
805
+ )
806
+ ] })
807
+ ] }),
808
+ x === "recovery" && h && /* @__PURE__ */ r("div", { className: "nice-2fa-setup__step", children: [
809
+ /* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: o(
810
+ "twoFaSetup.saveTheseRecoveryCodesIn",
811
+ "Save these recovery codes in a safe place. Each code can only be used once:"
812
+ ) }),
813
+ /* @__PURE__ */ e("div", { className: "nice-2fa-setup__recovery-codes", children: h.map(($, O) => /* @__PURE__ */ e("code", { className: "nice-2fa-setup__recovery-code", children: $ }, O)) }),
814
+ /* @__PURE__ */ e(
815
+ "button",
816
+ {
817
+ type: "button",
818
+ className: "nice-btn",
819
+ onClick: () => {
820
+ var $;
821
+ ($ = navigator.clipboard) == null || $.writeText(h.join(`
822
+ `)), I(!0);
823
+ },
824
+ children: N ? o("twoFaSetup.copied", "Copied!") : o("twoFaSetup.copyAllCodes", "Copy all codes")
825
+ }
826
+ ),
827
+ c && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: c, children: o("twoFaSetup.done", "Done") })
828
+ ] }),
829
+ c && x !== "recovery" && /* @__PURE__ */ e("button", { type: "button", className: "nice-2fa-setup__cancel", onClick: c, children: o("twoFaSetup.cancel", "Cancel") })
830
+ ]
831
+ }
832
+ );
833
+ }
834
+ ),
835
+ { displayName: "NiceTwoFaSetup" }
836
+ ), we = 500;
837
+ function V(s, a) {
838
+ return Math.floor(Math.random() * (a - s + 1)) + s;
792
839
  }
793
- function ye() {
840
+ function Ne() {
794
841
  return `${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
795
842
  }
796
- function ke(r, t) {
797
- switch (r) {
843
+ function ve(s, a) {
844
+ switch (s) {
798
845
  case "math": {
799
- const c = t === "easy" ? 5 : t === "hard" ? 20 : 10, n = V(1, c), i = V(1, c), h = t !== "easy" && n >= i && Math.random() < 0.5, l = h ? n - i : n + i;
800
- return { kind: "math", prompt: `${n} ${h ? "−" : "+"} ${i}`, answer: l };
846
+ const n = a === "easy" ? 5 : a === "hard" ? 20 : 10, t = V(1, n), i = V(1, n), d = a !== "easy" && t >= i && Math.random() < 0.5, l = d ? t - i : t + i;
847
+ return { kind: "math", prompt: `${t} ${d ? "−" : "+"} ${i}`, answer: l };
801
848
  }
802
849
  case "text": {
803
- const c = t === "easy" ? 4 : t === "hard" ? 7 : 5, n = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
850
+ const n = a === "easy" ? 4 : a === "hard" ? 7 : 5, t = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
804
851
  let i = "";
805
- for (let h = 0; h < c; h++)
806
- i += n[V(0, n.length - 1)];
852
+ for (let d = 0; d < n; d++)
853
+ i += t[V(0, t.length - 1)];
807
854
  return { kind: "text", text: i };
808
855
  }
809
856
  case "slider":
810
- return { kind: "slider", target: V(70, 92), tolerance: t === "easy" ? 8 : t === "hard" ? 2 : 4 };
857
+ return { kind: "slider", target: V(70, 92), tolerance: a === "easy" ? 8 : a === "hard" ? 2 : 4 };
811
858
  case "checkbox":
812
859
  default:
813
860
  return { kind: "checkbox" };
814
861
  }
815
862
  }
816
- function Ce(r, t, c) {
817
- if (!r)
863
+ function ye(s, a, n) {
864
+ if (!s)
818
865
  return;
819
- const n = r.getContext("2d");
820
- if (!n)
866
+ const t = s.getContext("2d");
867
+ if (!t)
821
868
  return;
822
- const i = r.width, h = r.height;
823
- n.clearRect(0, 0, i, h), n.fillStyle = c ? "#1a1a1a" : "#f3f4f6", n.fillRect(0, 0, i, h), n.strokeStyle = c ? "rgba(255,255,255,0.18)" : "rgba(0,0,0,0.18)", n.lineWidth = 1;
824
- for (let s = 0; s < 6; s++)
825
- n.beginPath(), n.moveTo(V(0, i), V(0, h)), n.lineTo(V(0, i), V(0, h)), n.stroke();
826
- n.fillStyle = c ? "#e5e7eb" : "#111827", n.textBaseline = "middle";
827
- const l = i / (t.length + 1);
828
- for (let s = 0; s < t.length; s++) {
829
- const u = V(22, 30);
830
- n.save(), n.translate(l * (s + 1), h / 2 + V(-4, 4)), n.rotate(V(-22, 22) * Math.PI / 180), n.font = `bold ${u}px monospace`, n.fillText(t[s], -u / 3, 0), n.restore();
869
+ const i = s.width, d = s.height;
870
+ t.clearRect(0, 0, i, d), t.fillStyle = n ? "#1a1a1a" : "#f3f4f6", t.fillRect(0, 0, i, d), t.strokeStyle = n ? "rgba(255,255,255,0.18)" : "rgba(0,0,0,0.18)", t.lineWidth = 1;
871
+ for (let c = 0; c < 6; c++)
872
+ t.beginPath(), t.moveTo(V(0, i), V(0, d)), t.lineTo(V(0, i), V(0, d)), t.stroke();
873
+ t.fillStyle = n ? "#e5e7eb" : "#111827", t.textBaseline = "middle";
874
+ const l = i / (a.length + 1);
875
+ for (let c = 0; c < a.length; c++) {
876
+ const h = V(22, 30);
877
+ t.save(), t.translate(l * (c + 1), d / 2 + V(-4, 4)), t.rotate(V(-22, 22) * Math.PI / 180), t.font = `bold ${h}px monospace`, t.fillText(a[c], -h / 3, 0), t.restore();
831
878
  }
832
879
  }
833
- const xe = j((r, t) => {
834
- const {
835
- variant: c,
836
- difficulty: n = "medium",
837
- refreshable: i = !0,
838
- verifyToken: h,
839
- expiresMs: l,
840
- label: s = "I'm not a robot",
841
- provider: u = "custom",
842
- siteKey: S,
843
- onVerify: d,
844
- onExpire: A,
845
- onError: b,
846
- onRefresh: k,
847
- theme: _ = "light",
848
- size: F = "normal",
849
- customRender: o,
850
- className: p,
851
- style: f
852
- } = r, M = H(null), w = H(null), C = H(void 0), [T, E] = g(0), [N, I] = g("idle"), [L, x] = g(""), [D, m] = g(""), [v, z] = g(0), R = ne(
853
- () => ke(c ?? "checkbox", n),
854
- [c, n, T]
855
- ), U = $(() => {
856
- I("idle"), x(""), m(""), z(0), E((y) => y + 1);
857
- }, []), P = $(() => {
858
- U(), k == null || k();
859
- }, [U, k]);
860
- oe(
861
- t,
862
- () => ({ reset: U, refresh: P, container: M.current }),
863
- [U, P]
864
- ), Q(() => {
865
- c === "text" && R.kind === "text" && Ce(w.current, R.text, _ === "dark");
866
- }, [c, R, _]), Q(() => {
867
- if (N !== "verified" || !l)
868
- return;
869
- const y = setTimeout(() => {
870
- A == null || A(), U();
871
- }, l);
872
- return () => clearTimeout(y);
873
- }, [N, l, A, U]);
874
- const O = $(() => {
875
- const y = `ntd-cap:${c}:${ye()}`;
876
- h ? (I("verifying"), x(""), Promise.resolve().then(() => h(y)).then((J) => {
877
- J ? (I("verified"), d == null || d(y)) : (I("error"), x("Verification failed. Please try again."), E((le) => le + 1), m(""));
878
- }).catch((J) => {
879
- I("error"), x("Verification error. Please try again."), b == null || b(J);
880
- })) : (I("verified"), d == null || d(y));
881
- }, [c, h, d, b]), q = $(() => {
882
- I("error"), x("Incorrect, please try again."), E((y) => y + 1), m("");
883
- }, []), ce = $(() => {
884
- N === "verifying" || N === "verified" || (I("verifying"), x(""), C.current = setTimeout(O, ve));
885
- }, [N, O]);
886
- Q(() => () => clearTimeout(C.current), []);
887
- const K = $(() => {
888
- R.kind === "math" ? D.trim() !== "" && Number(D) === R.answer ? O() : q() : R.kind === "text" && (D.trim().toUpperCase() === R.text ? O() : q());
889
- }, [R, D, O, q]), se = $(
890
- (y) => {
891
- z(y), !(R.kind !== "slider" || N === "verified" || N === "verifying") && Math.abs(y - R.target) <= R.tolerance && O();
892
- },
893
- [R, N, O]
894
- );
895
- if (!c)
896
- return u === "custom" && o ? /* @__PURE__ */ e(
897
- "div",
898
- {
899
- ref: M,
900
- className: `nice-captcha nice-captcha--custom${p ? ` ${p}` : ""}`,
901
- style: f,
902
- children: o
903
- }
904
- ) : /* @__PURE__ */ e(
880
+ const Re = /* @__PURE__ */ Object.assign(
881
+ /* @__PURE__ */ K((s, a) => {
882
+ const { t: n } = q(), {
883
+ variant: t,
884
+ difficulty: i = "medium",
885
+ refreshable: d = !0,
886
+ verifyToken: l,
887
+ expiresMs: c,
888
+ label: h = n("captcha.imNotARobot", "I'm not a robot"),
889
+ provider: x = "custom",
890
+ siteKey: f,
891
+ onVerify: g,
892
+ onExpire: S,
893
+ onError: y,
894
+ onRefresh: o,
895
+ theme: w = "light",
896
+ size: m = "normal",
897
+ customRender: p,
898
+ className: b,
899
+ style: N
900
+ } = s, I = Q(null), k = Q(null), T = Q(void 0), [$, O] = _(0), [v, E] = _("idle"), [L, A] = _(""), [D, u] = _(""), [C, H] = _(0), P = se(() => ve(t ?? "checkbox", i), [t, i, $]), U = M(() => {
901
+ E("idle"), A(""), u(""), H(0), O((F) => F + 1);
902
+ }, []), R = M(() => {
903
+ U(), o == null || o();
904
+ }, [U, o]);
905
+ me(
906
+ a,
907
+ () => ({ reset: U, refresh: R, container: I.current }),
908
+ [U, R]
909
+ ), Z(() => {
910
+ t === "text" && P.kind === "text" && ye(k.current, P.text, w === "dark");
911
+ }, [t, P, w]), Z(() => {
912
+ if (v !== "verified" || !c)
913
+ return;
914
+ const F = setTimeout(() => {
915
+ S == null || S(), U();
916
+ }, c);
917
+ return () => clearTimeout(F);
918
+ }, [v, c, S, U]);
919
+ const j = M(() => {
920
+ const F = `ntd-cap:${t}:${Ne()}`;
921
+ l ? (E("verifying"), A(""), Promise.resolve().then(() => l(F)).then((Y) => {
922
+ Y ? (E("verified"), g == null || g(F)) : (E("error"), A(
923
+ n(
924
+ "captcha.verificationFailedPleaseTryAgain",
925
+ "Verification failed. Please try again."
926
+ )
927
+ ), O((he) => he + 1), u(""));
928
+ }).catch((Y) => {
929
+ E("error"), A(
930
+ n("captcha.verificationErrorPleaseTryAgain", "Verification error. Please try again.")
931
+ ), y == null || y(Y);
932
+ })) : (E("verified"), g == null || g(F));
933
+ }, [t, l, g, y, n]), z = M(() => {
934
+ E("error"), A(n("captcha.incorrectPleaseTryAgain", "Incorrect, please try again.")), O((F) => F + 1), u("");
935
+ }, [n]), oe = M(() => {
936
+ v === "verifying" || v === "verified" || (E("verifying"), A(""), T.current = setTimeout(j, we));
937
+ }, [v, j]);
938
+ Z(() => () => clearTimeout(T.current), []);
939
+ const W = M(() => {
940
+ P.kind === "math" ? D.trim() !== "" && Number(D) === P.answer ? j() : z() : P.kind === "text" && (D.trim().toUpperCase() === P.text ? j() : z());
941
+ }, [P, D, j, z]), le = M(
942
+ (F) => {
943
+ H(F), !(P.kind !== "slider" || v === "verified" || v === "verifying") && Math.abs(F - P.target) <= P.tolerance && j();
944
+ },
945
+ [P, v, j]
946
+ );
947
+ if (!t)
948
+ return x === "custom" && p ? /* @__PURE__ */ e(
949
+ "div",
950
+ {
951
+ ref: I,
952
+ className: `nice-captcha nice-captcha--custom${b ? ` ${b}` : ""}`,
953
+ style: N,
954
+ children: p
955
+ }
956
+ ) : /* @__PURE__ */ e(
957
+ "div",
958
+ {
959
+ ref: I,
960
+ className: `nice-captcha nice-captcha--${x} nice-captcha--${w}${m === "compact" ? " nice-captcha--compact" : ""}${b ? ` ${b}` : ""}`,
961
+ style: N,
962
+ "data-sitekey": f,
963
+ "data-theme": w,
964
+ "data-size": m,
965
+ children: /* @__PURE__ */ r("div", { className: "nice-captcha__placeholder", children: [
966
+ /* @__PURE__ */ e("span", { children: n("captcha.captcha", "Captcha ({provider})").replace("{provider}", String(x)) }),
967
+ /* @__PURE__ */ e("p", { children: n(
968
+ "captcha.loadTheSdkToActivate",
969
+ "Load the {provider} SDK to activate verification."
970
+ ).replace("{provider}", String(x)) })
971
+ ] })
972
+ }
973
+ );
974
+ const B = v === "verifying", G = v === "verified", de = `nice-captcha nice-captcha--${t} nice-captcha--${w} nice-captcha--${v}${m === "compact" ? " nice-captcha--compact" : ""}${b ? ` ${b}` : ""}`;
975
+ return /* @__PURE__ */ r(
905
976
  "div",
906
977
  {
907
- ref: M,
908
- className: `nice-captcha nice-captcha--${u} nice-captcha--${_}${F === "compact" ? " nice-captcha--compact" : ""}${p ? ` ${p}` : ""}`,
909
- style: f,
910
- "data-sitekey": S,
911
- "data-theme": _,
912
- "data-size": F,
913
- children: /* @__PURE__ */ a("div", { className: "nice-captcha__placeholder", children: [
914
- /* @__PURE__ */ a("span", { children: [
915
- "Captcha (",
916
- u,
917
- ")"
918
- ] }),
919
- /* @__PURE__ */ a("p", { children: [
920
- "Load the ",
921
- u,
922
- " SDK to activate verification."
923
- ] })
924
- ] })
925
- }
926
- );
927
- const B = N === "verifying", G = N === "verified", ie = `nice-captcha nice-captcha--${c} nice-captcha--${_} nice-captcha--${N}${F === "compact" ? " nice-captcha--compact" : ""}${p ? ` ${p}` : ""}`;
928
- return /* @__PURE__ */ a(
929
- "div",
930
- {
931
- ref: M,
932
- className: ie,
933
- style: f,
934
- role: "group",
935
- "aria-label": "Captcha challenge",
936
- "data-variant": c,
937
- "data-status": N,
938
- "data-theme": _,
939
- children: [
940
- c === "checkbox" && /* @__PURE__ */ a(
941
- "button",
942
- {
943
- type: "button",
944
- className: "nice-captcha__checkbox",
945
- role: "checkbox",
946
- "aria-checked": G,
947
- "aria-busy": B,
948
- disabled: B || G,
949
- onClick: ce,
950
- children: [
951
- /* @__PURE__ */ e("span", { className: "nice-captcha__box", "aria-hidden": "true", children: B ? "…" : G ? /* @__PURE__ */ e(
952
- "span",
953
- {
954
- style: {
955
- display: "inline-block",
956
- width: "0.3em",
957
- height: "0.6em",
958
- marginBottom: "0.15em",
959
- borderRight: "0.12em solid currentColor",
960
- borderBottom: "0.12em solid currentColor",
961
- transform: "rotate(45deg)"
962
- }
963
- }
964
- ) : "" }),
965
- /* @__PURE__ */ e("span", { className: "nice-captcha__label", children: s })
966
- ]
967
- }
968
- ),
969
- c === "math" && R.kind === "math" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge", children: [
970
- /* @__PURE__ */ a("span", { className: "nice-captcha__prompt", "aria-hidden": "true", children: [
971
- R.prompt,
972
- " ="
973
- ] }),
974
- /* @__PURE__ */ e(
975
- "input",
976
- {
977
- className: "nice-input nice-captcha__answer",
978
- type: "number",
979
- inputMode: "numeric",
980
- value: D,
981
- "aria-label": `What is ${R.prompt}?`,
982
- disabled: B || G,
983
- onChange: (y) => m(y.target.value),
984
- onKeyDown: (y) => {
985
- y.key === "Enter" && (y.preventDefault(), K());
986
- }
987
- }
988
- ),
989
- /* @__PURE__ */ e(
978
+ ref: I,
979
+ className: de,
980
+ style: N,
981
+ role: "group",
982
+ "aria-label": n("captcha.captchaChallenge", "Captcha challenge"),
983
+ "data-variant": t,
984
+ "data-status": v,
985
+ "data-theme": w,
986
+ children: [
987
+ t === "checkbox" && /* @__PURE__ */ r(
990
988
  "button",
991
989
  {
992
990
  type: "button",
993
- className: "nice-btn nice-btn--primary nice-captcha__verify",
994
- disabled: B || G || D.trim() === "",
995
- onClick: K,
996
- children: B ? "…" : "Verify"
997
- }
998
- )
999
- ] }),
1000
- c === "text" && R.kind === "text" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge", children: [
1001
- /* @__PURE__ */ e(
1002
- "canvas",
1003
- {
1004
- ref: w,
1005
- className: "nice-captcha__canvas",
1006
- width: 160,
1007
- height: 56,
1008
- "aria-hidden": "true"
1009
- }
1010
- ),
1011
- /* @__PURE__ */ e(
1012
- "input",
1013
- {
1014
- className: "nice-input nice-captcha__answer",
1015
- type: "text",
1016
- autoCapitalize: "characters",
1017
- autoComplete: "off",
1018
- value: D,
1019
- "aria-label": "Type the characters shown in the image",
991
+ className: "nice-captcha__checkbox",
992
+ role: "checkbox",
993
+ "aria-checked": G,
994
+ "aria-busy": B,
1020
995
  disabled: B || G,
1021
- onChange: (y) => m(y.target.value),
1022
- onKeyDown: (y) => {
1023
- y.key === "Enter" && (y.preventDefault(), K());
1024
- }
996
+ onClick: oe,
997
+ children: [
998
+ /* @__PURE__ */ e("span", { className: "nice-captcha__box", "aria-hidden": "true", children: B ? "…" : G ? /* @__PURE__ */ e(
999
+ "span",
1000
+ {
1001
+ style: {
1002
+ display: "inline-block",
1003
+ width: "0.3em",
1004
+ height: "0.6em",
1005
+ marginBottom: "0.15em",
1006
+ borderRight: "0.12em solid currentColor",
1007
+ borderBottom: "0.12em solid currentColor",
1008
+ transform: "rotate(45deg)"
1009
+ }
1010
+ }
1011
+ ) : "" }),
1012
+ /* @__PURE__ */ e("span", { className: "nice-captcha__label", children: h })
1013
+ ]
1025
1014
  }
1026
1015
  ),
1027
- /* @__PURE__ */ e(
1028
- "button",
1029
- {
1030
- type: "button",
1031
- className: "nice-btn nice-btn--primary nice-captcha__verify",
1032
- disabled: B || G || D.trim() === "",
1033
- onClick: K,
1034
- children: B ? "…" : "Verify"
1035
- }
1036
- )
1037
- ] }),
1038
- c === "slider" && R.kind === "slider" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge nice-captcha__challenge--slider", children: [
1039
- /* @__PURE__ */ e("span", { className: "nice-captcha__slider-hint", "aria-hidden": "true", children: G ? "Verified" : "Slide to the marker" }),
1040
- /* @__PURE__ */ a("div", { className: "nice-captcha__track", children: [
1016
+ t === "math" && P.kind === "math" && /* @__PURE__ */ r("div", { className: "nice-captcha__challenge", children: [
1017
+ /* @__PURE__ */ r("span", { className: "nice-captcha__prompt", "aria-hidden": "true", children: [
1018
+ P.prompt,
1019
+ " ="
1020
+ ] }),
1021
+ /* @__PURE__ */ e(
1022
+ "input",
1023
+ {
1024
+ className: "nice-input nice-captcha__answer",
1025
+ type: "number",
1026
+ inputMode: "numeric",
1027
+ value: D,
1028
+ "aria-label": n("captcha.whatIs", "What is {prompt}?").replace(
1029
+ "{prompt}",
1030
+ String(P.prompt)
1031
+ ),
1032
+ disabled: B || G,
1033
+ onChange: (F) => u(F.target.value),
1034
+ onKeyDown: (F) => {
1035
+ F.key === "Enter" && (F.preventDefault(), W());
1036
+ }
1037
+ }
1038
+ ),
1039
+ /* @__PURE__ */ e(
1040
+ "button",
1041
+ {
1042
+ type: "button",
1043
+ className: "nice-btn nice-btn--primary nice-captcha__verify",
1044
+ disabled: B || G || D.trim() === "",
1045
+ onClick: W,
1046
+ children: B ? "…" : n("captcha.verify", "Verify")
1047
+ }
1048
+ )
1049
+ ] }),
1050
+ t === "text" && P.kind === "text" && /* @__PURE__ */ r("div", { className: "nice-captcha__challenge", children: [
1041
1051
  /* @__PURE__ */ e(
1042
- "span",
1052
+ "canvas",
1043
1053
  {
1044
- className: "nice-captcha__target",
1045
- "aria-hidden": "true",
1046
- style: { left: `${R.target}%` }
1054
+ ref: k,
1055
+ className: "nice-captcha__canvas",
1056
+ width: 160,
1057
+ height: 56,
1058
+ "aria-hidden": "true"
1047
1059
  }
1048
1060
  ),
1049
1061
  /* @__PURE__ */ e(
1050
1062
  "input",
1051
1063
  {
1052
- className: "nice-captcha__slider",
1053
- type: "range",
1054
- min: 0,
1055
- max: 100,
1056
- value: v,
1057
- "aria-label": "Slide the handle to the marker to verify",
1058
- "aria-valuetext": `${v}%`,
1059
- disabled: G || B,
1060
- onChange: (y) => se(Number(y.target.value))
1064
+ className: "nice-input nice-captcha__answer",
1065
+ type: "text",
1066
+ autoCapitalize: "characters",
1067
+ autoComplete: "off",
1068
+ value: D,
1069
+ "aria-label": n(
1070
+ "captcha.typeTheCharactersShownIn",
1071
+ "Type the characters shown in the image"
1072
+ ),
1073
+ disabled: B || G,
1074
+ onChange: (F) => u(F.target.value),
1075
+ onKeyDown: (F) => {
1076
+ F.key === "Enter" && (F.preventDefault(), W());
1077
+ }
1078
+ }
1079
+ ),
1080
+ /* @__PURE__ */ e(
1081
+ "button",
1082
+ {
1083
+ type: "button",
1084
+ className: "nice-btn nice-btn--primary nice-captcha__verify",
1085
+ disabled: B || G || D.trim() === "",
1086
+ onClick: W,
1087
+ children: B ? "…" : n("captcha.verify", "Verify")
1088
+ }
1089
+ )
1090
+ ] }),
1091
+ t === "slider" && P.kind === "slider" && /* @__PURE__ */ r("div", { className: "nice-captcha__challenge nice-captcha__challenge--slider", children: [
1092
+ /* @__PURE__ */ e("span", { className: "nice-captcha__slider-hint", "aria-hidden": "true", children: G ? n("captcha.verified", "Verified") : n("captcha.slideToTheMarker", "Slide to the marker") }),
1093
+ /* @__PURE__ */ r("div", { className: "nice-captcha__track", children: [
1094
+ /* @__PURE__ */ e(
1095
+ "span",
1096
+ {
1097
+ className: "nice-captcha__target",
1098
+ "aria-hidden": "true",
1099
+ style: { left: `${P.target}%` }
1100
+ }
1101
+ ),
1102
+ /* @__PURE__ */ e(
1103
+ "input",
1104
+ {
1105
+ className: "nice-captcha__slider",
1106
+ type: "range",
1107
+ min: 0,
1108
+ max: 100,
1109
+ value: C,
1110
+ "aria-label": n(
1111
+ "captcha.slideTheHandleToThe",
1112
+ "Slide the handle to the marker to verify"
1113
+ ),
1114
+ "aria-valuetext": `${C}%`,
1115
+ disabled: G || B,
1116
+ onChange: (F) => le(Number(F.target.value))
1117
+ }
1118
+ )
1119
+ ] })
1120
+ ] }),
1121
+ /* @__PURE__ */ r("div", { className: "nice-captcha__footer", children: [
1122
+ /* @__PURE__ */ e("div", { className: "nice-captcha__message", role: "status", "aria-live": "polite", children: L }),
1123
+ d && /* @__PURE__ */ e(
1124
+ "button",
1125
+ {
1126
+ type: "button",
1127
+ className: "nice-captcha__refresh",
1128
+ "aria-label": n("captcha.refreshChallenge", "Refresh challenge"),
1129
+ title: n("captcha.refreshChallenge", "Refresh challenge"),
1130
+ onClick: R,
1131
+ children: /* @__PURE__ */ e(ie, {})
1061
1132
  }
1062
1133
  )
1063
1134
  ] })
1064
- ] }),
1065
- /* @__PURE__ */ a("div", { className: "nice-captcha__footer", children: [
1066
- /* @__PURE__ */ e("div", { className: "nice-captcha__message", role: "status", "aria-live": "polite", children: L }),
1067
- i && /* @__PURE__ */ e(
1068
- "button",
1069
- {
1070
- type: "button",
1071
- className: "nice-captcha__refresh",
1072
- "aria-label": "Refresh challenge",
1073
- title: "Refresh challenge",
1074
- onClick: P,
1075
- children: /* @__PURE__ */ e(re, {})
1076
- }
1077
- )
1078
- ] })
1079
- ]
1080
- }
1081
- );
1082
- });
1083
- xe.displayName = "NiceCaptcha";
1084
- const $e = [
1135
+ ]
1136
+ }
1137
+ );
1138
+ }),
1139
+ { displayName: "NiceCaptcha" }
1140
+ ), ke = [
1085
1141
  { id: "google", label: "Google", color: "#4285f4", textColor: "#fff" },
1086
1142
  { id: "microsoft", label: "Microsoft", color: "#00a4ef", textColor: "#fff" },
1087
1143
  { id: "discord", label: "Discord", color: "#5865f2", textColor: "#fff" },
1088
1144
  { id: "spotify", label: "Spotify", color: "#1db954", textColor: "#fff" },
1089
1145
  { id: "github", label: "GitHub", color: "#24292e", textColor: "#fff" }
1090
- ], Ae = j(
1091
- ({
1092
- providers: r = $e,
1093
- onProviderClick: t,
1094
- disabled: c = !1,
1095
- loadingProvider: n,
1096
- direction: i = "vertical",
1097
- separatorText: h = "or continue with",
1098
- showSeparator: l = !0,
1099
- className: s,
1100
- style: u
1101
- }, S) => /* @__PURE__ */ a(
1102
- "div",
1103
- {
1104
- ref: S,
1105
- className: `nice-oauth nice-oauth--${i}${s ? ` ${s}` : ""}`,
1106
- style: u,
1107
- children: [
1108
- l && /* @__PURE__ */ a("div", { className: "nice-oauth__separator", children: [
1109
- /* @__PURE__ */ e("hr", {}),
1110
- /* @__PURE__ */ e("span", { children: h }),
1111
- /* @__PURE__ */ e("hr", {})
1112
- ] }),
1113
- /* @__PURE__ */ e("div", { className: "nice-oauth__buttons", children: r.map((d) => /* @__PURE__ */ a(
1114
- "button",
1115
- {
1116
- type: "button",
1117
- className: `nice-oauth__btn${n === d.id ? " nice-oauth__btn--loading" : ""}`,
1118
- style: { backgroundColor: d.color, color: d.textColor },
1119
- onClick: () => t == null ? void 0 : t(d.id),
1120
- disabled: c || !!n,
1121
- children: [
1122
- d.icon && /* @__PURE__ */ e("span", { className: "nice-oauth__btn-icon", children: d.icon }),
1123
- /* @__PURE__ */ e("span", { className: "nice-oauth__btn-label", children: n === d.id ? "…" : d.label })
1124
- ]
1125
- },
1126
- d.id
1127
- )) })
1128
- ]
1146
+ ], Ie = /* @__PURE__ */ Object.assign(
1147
+ /* @__PURE__ */ K(
1148
+ ({
1149
+ providers: s = ke,
1150
+ onProviderClick: a,
1151
+ disabled: n = !1,
1152
+ loadingProvider: t,
1153
+ direction: i = "vertical",
1154
+ separatorText: d,
1155
+ showSeparator: l = !0,
1156
+ className: c,
1157
+ style: h
1158
+ }, x) => {
1159
+ const { t: f } = q();
1160
+ return /* @__PURE__ */ r(
1161
+ "div",
1162
+ {
1163
+ ref: x,
1164
+ className: `nice-oauth nice-oauth--${i}${c ? ` ${c}` : ""}`,
1165
+ style: h,
1166
+ children: [
1167
+ l && /* @__PURE__ */ r("div", { className: "nice-oauth__separator", children: [
1168
+ /* @__PURE__ */ e("hr", {}),
1169
+ /* @__PURE__ */ e("span", { children: d ?? f("oAuthButtons.orContinueWith", "or continue with") }),
1170
+ /* @__PURE__ */ e("hr", {})
1171
+ ] }),
1172
+ /* @__PURE__ */ e("div", { className: "nice-oauth__buttons", children: s.map((g) => /* @__PURE__ */ r(
1173
+ "button",
1174
+ {
1175
+ type: "button",
1176
+ className: `nice-oauth__btn${t === g.id ? " nice-oauth__btn--loading" : ""}`,
1177
+ style: { backgroundColor: g.color, color: g.textColor },
1178
+ onClick: () => a == null ? void 0 : a(g.id),
1179
+ disabled: n || !!t,
1180
+ children: [
1181
+ g.icon && /* @__PURE__ */ e("span", { className: "nice-oauth__btn-icon", children: g.icon }),
1182
+ /* @__PURE__ */ e("span", { className: "nice-oauth__btn-label", children: t === g.id ? "…" : g.label })
1183
+ ]
1184
+ },
1185
+ g.id
1186
+ )) })
1187
+ ]
1188
+ }
1189
+ );
1129
1190
  }
1130
- )
1131
- );
1132
- Ae.displayName = "NiceOAuthButtons";
1133
- const Me = j(
1134
- function(t, c) {
1135
- const {
1136
- tokens: n,
1137
- onCreate: i,
1138
- onRevoke: h,
1139
- availableScopes: l = [],
1140
- maxTokens: s = 10,
1141
- title: u = "API Tokens",
1142
- className: S,
1143
- style: d
1144
- } = t, [A, b] = g(!1), [k, _] = g(""), [F, o] = g([]), [p, f] = g("90"), [M, w] = g(null), [C, T] = g(!1), [E, N] = g(null), I = $(async () => {
1145
- if (!(!i || !k.trim())) {
1146
- T(!0);
1191
+ ),
1192
+ { displayName: "NiceOAuthButtons" }
1193
+ ), De = /* @__PURE__ */ K(function(a, n) {
1194
+ const { t } = q(), {
1195
+ tokens: i,
1196
+ onCreate: d,
1197
+ onRevoke: l,
1198
+ availableScopes: c = [],
1199
+ maxTokens: h = 10,
1200
+ title: x = t("tokenManagement.apiTokens", "API Tokens"),
1201
+ className: f,
1202
+ style: g
1203
+ } = a, [S, y] = _(!1), [o, w] = _(""), [m, p] = _([]), [b, N] = _("90"), [I, k] = _(null), [T, $] = _(!1), [O, v] = _(null), E = M(async () => {
1204
+ if (!(!d || !o.trim())) {
1205
+ $(!0);
1206
+ try {
1207
+ const u = b ? parseInt(b, 10) : void 0, C = await d(o.trim(), m, u);
1208
+ k(C), w(""), p([]), y(!1);
1209
+ } finally {
1210
+ $(!1);
1211
+ }
1212
+ }
1213
+ }, [d, o, m, b]), L = M(
1214
+ async (u) => {
1215
+ if (l) {
1216
+ v(u);
1147
1217
  try {
1148
- const m = p ? parseInt(p, 10) : void 0, v = await i(k.trim(), F, m);
1149
- w(v), _(""), o([]), b(!1);
1218
+ await l(u);
1150
1219
  } finally {
1151
- T(!1);
1220
+ v(null);
1152
1221
  }
1153
1222
  }
1154
- }, [i, k, F, p]), L = $(
1155
- async (m) => {
1156
- if (h) {
1157
- N(m);
1158
- try {
1159
- await h(m);
1160
- } finally {
1161
- N(null);
1162
- }
1223
+ },
1224
+ [l]
1225
+ ), A = (u) => {
1226
+ p(
1227
+ (C) => C.includes(u) ? C.filter((H) => H !== u) : [...C, u]
1228
+ );
1229
+ }, D = i.length < h;
1230
+ return /* @__PURE__ */ r("div", { ref: n, className: `nice-token-management ${f ?? ""}`, style: g, children: [
1231
+ /* @__PURE__ */ r("div", { className: "nice-token-management__header", children: [
1232
+ /* @__PURE__ */ e("h3", { children: x }),
1233
+ D && /* @__PURE__ */ e(
1234
+ "button",
1235
+ {
1236
+ className: "nice-token-management__new-btn",
1237
+ onClick: () => y(!0),
1238
+ disabled: S,
1239
+ children: t("tokenManagement.newToken", "+ New Token")
1163
1240
  }
1164
- },
1165
- [h]
1166
- ), x = (m) => {
1167
- o(
1168
- (v) => v.includes(m) ? v.filter((z) => z !== m) : [...v, m]
1169
- );
1170
- }, D = n.length < s;
1171
- return /* @__PURE__ */ a("div", { ref: c, className: `nice-token-management ${S ?? ""}`, style: d, children: [
1172
- /* @__PURE__ */ a("div", { className: "nice-token-management__header", children: [
1173
- /* @__PURE__ */ e("h3", { children: u }),
1174
- D && /* @__PURE__ */ e(
1175
- "button",
1241
+ )
1242
+ ] }),
1243
+ I && /* @__PURE__ */ r("div", { className: "nice-token-management__reveal", children: [
1244
+ /* @__PURE__ */ r("p", { children: [
1245
+ /* @__PURE__ */ e("strong", { children: t("tokenManagement.newTokenCreated", "New token created!") }),
1246
+ " ",
1247
+ t("tokenManagement.copyItNowItWont", "Copy it now — it won't be shown again.")
1248
+ ] }),
1249
+ /* @__PURE__ */ e("code", { className: "nice-token-management__token-value", children: I }),
1250
+ /* @__PURE__ */ e("button", { onClick: () => k(null), children: t("tokenManagement.dismiss", "Dismiss") })
1251
+ ] }),
1252
+ S && /* @__PURE__ */ r("div", { className: "nice-token-management__create-form", children: [
1253
+ /* @__PURE__ */ r("label", { children: [
1254
+ t("tokenManagement.name", "Name"),
1255
+ /* @__PURE__ */ e(
1256
+ "input",
1176
1257
  {
1177
- className: "nice-token-management__new-btn",
1178
- onClick: () => b(!0),
1179
- disabled: A,
1180
- children: "+ New Token"
1258
+ type: "text",
1259
+ value: o,
1260
+ onChange: (u) => w(u.target.value),
1261
+ placeholder: t("tokenManagement.myApiToken", "My API token"),
1262
+ maxLength: 64
1181
1263
  }
1182
1264
  )
1183
1265
  ] }),
1184
- M && /* @__PURE__ */ a("div", { className: "nice-token-management__reveal", children: [
1185
- /* @__PURE__ */ a("p", { children: [
1186
- /* @__PURE__ */ e("strong", { children: "New token created!" }),
1187
- " Copy it now — it won't be shown again."
1188
- ] }),
1189
- /* @__PURE__ */ e("code", { className: "nice-token-management__token-value", children: M }),
1190
- /* @__PURE__ */ e("button", { onClick: () => w(null), children: "Dismiss" })
1191
- ] }),
1192
- A && /* @__PURE__ */ a("div", { className: "nice-token-management__create-form", children: [
1193
- /* @__PURE__ */ a("label", { children: [
1194
- "Name",
1266
+ c.length > 0 && /* @__PURE__ */ r("fieldset", { children: [
1267
+ /* @__PURE__ */ e("legend", { children: t("tokenManagement.scopes", "Scopes") }),
1268
+ c.map((u) => /* @__PURE__ */ r("label", { className: "nice-token-management__scope", children: [
1195
1269
  /* @__PURE__ */ e(
1196
1270
  "input",
1197
1271
  {
1198
- type: "text",
1199
- value: k,
1200
- onChange: (m) => _(m.target.value),
1201
- placeholder: "My API token",
1202
- maxLength: 64
1272
+ type: "checkbox",
1273
+ checked: m.includes(u),
1274
+ onChange: () => A(u)
1203
1275
  }
1204
- )
1205
- ] }),
1206
- l.length > 0 && /* @__PURE__ */ a("fieldset", { children: [
1207
- /* @__PURE__ */ e("legend", { children: "Scopes" }),
1208
- l.map((m) => /* @__PURE__ */ a("label", { className: "nice-token-management__scope", children: [
1209
- /* @__PURE__ */ e(
1210
- "input",
1211
- {
1212
- type: "checkbox",
1213
- checked: F.includes(m),
1214
- onChange: () => x(m)
1215
- }
1216
- ),
1217
- m
1218
- ] }, m))
1219
- ] }),
1220
- /* @__PURE__ */ a("label", { children: [
1221
- "Expires in (days)",
1222
- /* @__PURE__ */ e(
1223
- "input",
1224
- {
1225
- type: "number",
1226
- value: p,
1227
- onChange: (m) => f(m.target.value),
1228
- min: 1,
1229
- max: 365
1230
- }
1231
- )
1232
- ] }),
1233
- /* @__PURE__ */ a("div", { className: "nice-token-management__create-actions", children: [
1234
- /* @__PURE__ */ e("button", { onClick: I, disabled: C || !k.trim(), children: C ? "Creating…" : "Create Token" }),
1235
- /* @__PURE__ */ e("button", { onClick: () => b(!1), children: "Cancel" })
1236
- ] })
1276
+ ),
1277
+ u
1278
+ ] }, u))
1237
1279
  ] }),
1238
- n.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-token-management__empty", children: "No API tokens yet." }) : /* @__PURE__ */ a("table", { className: "nice-token-management__table", children: [
1239
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ a("tr", { children: [
1240
- /* @__PURE__ */ e("th", { children: "Name" }),
1241
- /* @__PURE__ */ e("th", { children: "Prefix" }),
1242
- /* @__PURE__ */ e("th", { children: "Created" }),
1243
- /* @__PURE__ */ e("th", { children: "Expires" }),
1244
- /* @__PURE__ */ e("th", { children: "Last Used" }),
1245
- /* @__PURE__ */ e("th", { children: "Scopes" }),
1246
- /* @__PURE__ */ e("th", {})
1247
- ] }) }),
1248
- /* @__PURE__ */ e("tbody", { children: n.map((m) => {
1249
- var v;
1250
- return /* @__PURE__ */ a("tr", { children: [
1251
- /* @__PURE__ */ e("td", { children: m.name }),
1252
- /* @__PURE__ */ e("td", { children: /* @__PURE__ */ a("code", { children: [
1253
- m.prefix,
1254
- "…"
1255
- ] }) }),
1256
- /* @__PURE__ */ e("td", { children: m.createdAt }),
1257
- /* @__PURE__ */ e("td", { children: m.expiresAt ?? "—" }),
1258
- /* @__PURE__ */ e("td", { children: m.lastUsedAt ?? "Never" }),
1259
- /* @__PURE__ */ e("td", { children: ((v = m.scopes) == null ? void 0 : v.join(", ")) || "—" }),
1260
- /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
1261
- "button",
1262
- {
1263
- className: "nice-token-management__revoke-btn",
1264
- onClick: () => L(m.id),
1265
- disabled: E === m.id,
1266
- children: E === m.id ? "Revoking…" : "Revoke"
1267
- }
1268
- ) })
1269
- ] }, m.id);
1270
- }) })
1280
+ /* @__PURE__ */ r("label", { children: [
1281
+ t("tokenManagement.expiresInDays", "Expires in (days)"),
1282
+ /* @__PURE__ */ e(
1283
+ "input",
1284
+ {
1285
+ type: "number",
1286
+ value: b,
1287
+ onChange: (u) => N(u.target.value),
1288
+ min: 1,
1289
+ max: 365
1290
+ }
1291
+ )
1292
+ ] }),
1293
+ /* @__PURE__ */ r("div", { className: "nice-token-management__create-actions", children: [
1294
+ /* @__PURE__ */ e("button", { onClick: E, disabled: T || !o.trim(), children: T ? t("tokenManagement.creating", "Creating…") : t("tokenManagement.createToken", "Create Token") }),
1295
+ /* @__PURE__ */ e("button", { onClick: () => y(!1), children: t("tokenManagement.cancel", "Cancel") })
1271
1296
  ] })
1272
- ] });
1273
- }
1274
- );
1297
+ ] }),
1298
+ i.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-token-management__empty", children: t("tokenManagement.noApiTokensYet", "No API tokens yet.") }) : /* @__PURE__ */ r("table", { className: "nice-token-management__table", children: [
1299
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { children: [
1300
+ /* @__PURE__ */ e("th", { children: t("tokenManagement.name", "Name") }),
1301
+ /* @__PURE__ */ e("th", { children: t("tokenManagement.prefix", "Prefix") }),
1302
+ /* @__PURE__ */ e("th", { children: t("tokenManagement.created", "Created") }),
1303
+ /* @__PURE__ */ e("th", { children: t("tokenManagement.expires", "Expires") }),
1304
+ /* @__PURE__ */ e("th", { children: t("tokenManagement.lastUsed", "Last Used") }),
1305
+ /* @__PURE__ */ e("th", { children: t("tokenManagement.scopes", "Scopes") }),
1306
+ /* @__PURE__ */ e("th", {})
1307
+ ] }) }),
1308
+ /* @__PURE__ */ e("tbody", { children: i.map((u) => {
1309
+ var C;
1310
+ return /* @__PURE__ */ r("tr", { children: [
1311
+ /* @__PURE__ */ e("td", { children: u.name }),
1312
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ r("code", { children: [
1313
+ u.prefix,
1314
+ "…"
1315
+ ] }) }),
1316
+ /* @__PURE__ */ e("td", { children: u.createdAt }),
1317
+ /* @__PURE__ */ e("td", { children: u.expiresAt ?? "—" }),
1318
+ /* @__PURE__ */ e("td", { children: u.lastUsedAt ?? t("tokenManagement.never", "Never") }),
1319
+ /* @__PURE__ */ e("td", { children: ((C = u.scopes) == null ? void 0 : C.join(", ")) || "—" }),
1320
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
1321
+ "button",
1322
+ {
1323
+ className: "nice-token-management__revoke-btn",
1324
+ onClick: () => L(u.id),
1325
+ disabled: O === u.id,
1326
+ children: O === u.id ? t("tokenManagement.revoking", "Revoking…") : t("tokenManagement.revoke", "Revoke")
1327
+ }
1328
+ ) })
1329
+ ] }, u.id);
1330
+ }) })
1331
+ ] })
1332
+ ] });
1333
+ });
1275
1334
  export {
1276
- xe as NiceCaptcha,
1277
- Ne as NiceChangePassword,
1278
- de as NiceLoginForm,
1279
- Ae as NiceOAuthButtons,
1280
- Fe as NicePasswordGenerator,
1281
- Z as NicePasswordStrength,
1282
- me as NiceRegistrationForm,
1283
- Me as NiceTokenManagement,
1284
- we as NiceTwoFaSetup,
1285
- Y as calcPasswordStrength,
1286
- te as generatePassword,
1287
- Re as useAuth
1335
+ Re as NiceCaptcha,
1336
+ $e as NiceChangePassword,
1337
+ Te as NiceLoginForm,
1338
+ Ie as NiceOAuthButtons,
1339
+ Me as NicePasswordGenerator,
1340
+ te as NicePasswordStrength,
1341
+ Ae as NiceRegistrationForm,
1342
+ De as NiceTokenManagement,
1343
+ Pe as NiceTwoFaSetup,
1344
+ ee as calcPasswordStrength,
1345
+ re as generatePassword,
1346
+ Se as useAuth
1288
1347
  };