@nice2dev/auth 1.2.0 → 1.2.1

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