@rqdhw3n/react-auth-flow 1.0.0 → 1.0.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.
@@ -0,0 +1,1865 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const require$$0 = require("react");
4
+ const reactRouterDom = require("react-router-dom");
5
+ var jsxRuntime = { exports: {} };
6
+ var reactJsxRuntime_production_min = {};
7
+ /**
8
+ * @license React
9
+ * react-jsx-runtime.production.min.js
10
+ *
11
+ * Copyright (c) Facebook, Inc. and its affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ var hasRequiredReactJsxRuntime_production_min;
17
+ function requireReactJsxRuntime_production_min() {
18
+ if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
19
+ hasRequiredReactJsxRuntime_production_min = 1;
20
+ var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
21
+ function q(c, a, g) {
22
+ var b, d = {}, e = null, h = null;
23
+ void 0 !== g && (e = "" + g);
24
+ void 0 !== a.key && (e = "" + a.key);
25
+ void 0 !== a.ref && (h = a.ref);
26
+ for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
27
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
28
+ return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
29
+ }
30
+ reactJsxRuntime_production_min.Fragment = l;
31
+ reactJsxRuntime_production_min.jsx = q;
32
+ reactJsxRuntime_production_min.jsxs = q;
33
+ return reactJsxRuntime_production_min;
34
+ }
35
+ var reactJsxRuntime_development = {};
36
+ /**
37
+ * @license React
38
+ * react-jsx-runtime.development.js
39
+ *
40
+ * Copyright (c) Facebook, Inc. and its affiliates.
41
+ *
42
+ * This source code is licensed under the MIT license found in the
43
+ * LICENSE file in the root directory of this source tree.
44
+ */
45
+ var hasRequiredReactJsxRuntime_development;
46
+ function requireReactJsxRuntime_development() {
47
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
48
+ hasRequiredReactJsxRuntime_development = 1;
49
+ if (process.env.NODE_ENV !== "production") {
50
+ (function() {
51
+ var React = require$$0;
52
+ var REACT_ELEMENT_TYPE = Symbol.for("react.element");
53
+ var REACT_PORTAL_TYPE = Symbol.for("react.portal");
54
+ var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
55
+ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
56
+ var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
57
+ var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
58
+ var REACT_CONTEXT_TYPE = Symbol.for("react.context");
59
+ var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
60
+ var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
61
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
62
+ var REACT_MEMO_TYPE = Symbol.for("react.memo");
63
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
64
+ var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
65
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
66
+ var FAUX_ITERATOR_SYMBOL = "@@iterator";
67
+ function getIteratorFn(maybeIterable) {
68
+ if (maybeIterable === null || typeof maybeIterable !== "object") {
69
+ return null;
70
+ }
71
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
72
+ if (typeof maybeIterator === "function") {
73
+ return maybeIterator;
74
+ }
75
+ return null;
76
+ }
77
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
78
+ function error(format) {
79
+ {
80
+ {
81
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
82
+ args[_key2 - 1] = arguments[_key2];
83
+ }
84
+ printWarning("error", format, args);
85
+ }
86
+ }
87
+ }
88
+ function printWarning(level, format, args) {
89
+ {
90
+ var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
91
+ var stack = ReactDebugCurrentFrame2.getStackAddendum();
92
+ if (stack !== "") {
93
+ format += "%s";
94
+ args = args.concat([stack]);
95
+ }
96
+ var argsWithFormat = args.map(function(item) {
97
+ return String(item);
98
+ });
99
+ argsWithFormat.unshift("Warning: " + format);
100
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
101
+ }
102
+ }
103
+ var enableScopeAPI = false;
104
+ var enableCacheElement = false;
105
+ var enableTransitionTracing = false;
106
+ var enableLegacyHidden = false;
107
+ var enableDebugTracing = false;
108
+ var REACT_MODULE_REFERENCE;
109
+ {
110
+ REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
111
+ }
112
+ function isValidElementType(type) {
113
+ if (typeof type === "string" || typeof type === "function") {
114
+ return true;
115
+ }
116
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
117
+ return true;
118
+ }
119
+ if (typeof type === "object" && type !== null) {
120
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
121
+ // types supported by any Flight configuration anywhere since
122
+ // we don't know which Flight build this will end up being used
123
+ // with.
124
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
125
+ return true;
126
+ }
127
+ }
128
+ return false;
129
+ }
130
+ function getWrappedName(outerType, innerType, wrapperName) {
131
+ var displayName = outerType.displayName;
132
+ if (displayName) {
133
+ return displayName;
134
+ }
135
+ var functionName = innerType.displayName || innerType.name || "";
136
+ return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
137
+ }
138
+ function getContextName(type) {
139
+ return type.displayName || "Context";
140
+ }
141
+ function getComponentNameFromType(type) {
142
+ if (type == null) {
143
+ return null;
144
+ }
145
+ {
146
+ if (typeof type.tag === "number") {
147
+ error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
148
+ }
149
+ }
150
+ if (typeof type === "function") {
151
+ return type.displayName || type.name || null;
152
+ }
153
+ if (typeof type === "string") {
154
+ return type;
155
+ }
156
+ switch (type) {
157
+ case REACT_FRAGMENT_TYPE:
158
+ return "Fragment";
159
+ case REACT_PORTAL_TYPE:
160
+ return "Portal";
161
+ case REACT_PROFILER_TYPE:
162
+ return "Profiler";
163
+ case REACT_STRICT_MODE_TYPE:
164
+ return "StrictMode";
165
+ case REACT_SUSPENSE_TYPE:
166
+ return "Suspense";
167
+ case REACT_SUSPENSE_LIST_TYPE:
168
+ return "SuspenseList";
169
+ }
170
+ if (typeof type === "object") {
171
+ switch (type.$$typeof) {
172
+ case REACT_CONTEXT_TYPE:
173
+ var context = type;
174
+ return getContextName(context) + ".Consumer";
175
+ case REACT_PROVIDER_TYPE:
176
+ var provider = type;
177
+ return getContextName(provider._context) + ".Provider";
178
+ case REACT_FORWARD_REF_TYPE:
179
+ return getWrappedName(type, type.render, "ForwardRef");
180
+ case REACT_MEMO_TYPE:
181
+ var outerName = type.displayName || null;
182
+ if (outerName !== null) {
183
+ return outerName;
184
+ }
185
+ return getComponentNameFromType(type.type) || "Memo";
186
+ case REACT_LAZY_TYPE: {
187
+ var lazyComponent = type;
188
+ var payload = lazyComponent._payload;
189
+ var init = lazyComponent._init;
190
+ try {
191
+ return getComponentNameFromType(init(payload));
192
+ } catch (x) {
193
+ return null;
194
+ }
195
+ }
196
+ }
197
+ }
198
+ return null;
199
+ }
200
+ var assign = Object.assign;
201
+ var disabledDepth = 0;
202
+ var prevLog;
203
+ var prevInfo;
204
+ var prevWarn;
205
+ var prevError;
206
+ var prevGroup;
207
+ var prevGroupCollapsed;
208
+ var prevGroupEnd;
209
+ function disabledLog() {
210
+ }
211
+ disabledLog.__reactDisabledLog = true;
212
+ function disableLogs() {
213
+ {
214
+ if (disabledDepth === 0) {
215
+ prevLog = console.log;
216
+ prevInfo = console.info;
217
+ prevWarn = console.warn;
218
+ prevError = console.error;
219
+ prevGroup = console.group;
220
+ prevGroupCollapsed = console.groupCollapsed;
221
+ prevGroupEnd = console.groupEnd;
222
+ var props = {
223
+ configurable: true,
224
+ enumerable: true,
225
+ value: disabledLog,
226
+ writable: true
227
+ };
228
+ Object.defineProperties(console, {
229
+ info: props,
230
+ log: props,
231
+ warn: props,
232
+ error: props,
233
+ group: props,
234
+ groupCollapsed: props,
235
+ groupEnd: props
236
+ });
237
+ }
238
+ disabledDepth++;
239
+ }
240
+ }
241
+ function reenableLogs() {
242
+ {
243
+ disabledDepth--;
244
+ if (disabledDepth === 0) {
245
+ var props = {
246
+ configurable: true,
247
+ enumerable: true,
248
+ writable: true
249
+ };
250
+ Object.defineProperties(console, {
251
+ log: assign({}, props, {
252
+ value: prevLog
253
+ }),
254
+ info: assign({}, props, {
255
+ value: prevInfo
256
+ }),
257
+ warn: assign({}, props, {
258
+ value: prevWarn
259
+ }),
260
+ error: assign({}, props, {
261
+ value: prevError
262
+ }),
263
+ group: assign({}, props, {
264
+ value: prevGroup
265
+ }),
266
+ groupCollapsed: assign({}, props, {
267
+ value: prevGroupCollapsed
268
+ }),
269
+ groupEnd: assign({}, props, {
270
+ value: prevGroupEnd
271
+ })
272
+ });
273
+ }
274
+ if (disabledDepth < 0) {
275
+ error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
276
+ }
277
+ }
278
+ }
279
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
280
+ var prefix;
281
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
282
+ {
283
+ if (prefix === void 0) {
284
+ try {
285
+ throw Error();
286
+ } catch (x) {
287
+ var match = x.stack.trim().match(/\n( *(at )?)/);
288
+ prefix = match && match[1] || "";
289
+ }
290
+ }
291
+ return "\n" + prefix + name;
292
+ }
293
+ }
294
+ var reentry = false;
295
+ var componentFrameCache;
296
+ {
297
+ var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
298
+ componentFrameCache = new PossiblyWeakMap();
299
+ }
300
+ function describeNativeComponentFrame(fn, construct) {
301
+ if (!fn || reentry) {
302
+ return "";
303
+ }
304
+ {
305
+ var frame = componentFrameCache.get(fn);
306
+ if (frame !== void 0) {
307
+ return frame;
308
+ }
309
+ }
310
+ var control;
311
+ reentry = true;
312
+ var previousPrepareStackTrace = Error.prepareStackTrace;
313
+ Error.prepareStackTrace = void 0;
314
+ var previousDispatcher;
315
+ {
316
+ previousDispatcher = ReactCurrentDispatcher.current;
317
+ ReactCurrentDispatcher.current = null;
318
+ disableLogs();
319
+ }
320
+ try {
321
+ if (construct) {
322
+ var Fake = function() {
323
+ throw Error();
324
+ };
325
+ Object.defineProperty(Fake.prototype, "props", {
326
+ set: function() {
327
+ throw Error();
328
+ }
329
+ });
330
+ if (typeof Reflect === "object" && Reflect.construct) {
331
+ try {
332
+ Reflect.construct(Fake, []);
333
+ } catch (x) {
334
+ control = x;
335
+ }
336
+ Reflect.construct(fn, [], Fake);
337
+ } else {
338
+ try {
339
+ Fake.call();
340
+ } catch (x) {
341
+ control = x;
342
+ }
343
+ fn.call(Fake.prototype);
344
+ }
345
+ } else {
346
+ try {
347
+ throw Error();
348
+ } catch (x) {
349
+ control = x;
350
+ }
351
+ fn();
352
+ }
353
+ } catch (sample) {
354
+ if (sample && control && typeof sample.stack === "string") {
355
+ var sampleLines = sample.stack.split("\n");
356
+ var controlLines = control.stack.split("\n");
357
+ var s = sampleLines.length - 1;
358
+ var c = controlLines.length - 1;
359
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
360
+ c--;
361
+ }
362
+ for (; s >= 1 && c >= 0; s--, c--) {
363
+ if (sampleLines[s] !== controlLines[c]) {
364
+ if (s !== 1 || c !== 1) {
365
+ do {
366
+ s--;
367
+ c--;
368
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
369
+ var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
370
+ if (fn.displayName && _frame.includes("<anonymous>")) {
371
+ _frame = _frame.replace("<anonymous>", fn.displayName);
372
+ }
373
+ {
374
+ if (typeof fn === "function") {
375
+ componentFrameCache.set(fn, _frame);
376
+ }
377
+ }
378
+ return _frame;
379
+ }
380
+ } while (s >= 1 && c >= 0);
381
+ }
382
+ break;
383
+ }
384
+ }
385
+ }
386
+ } finally {
387
+ reentry = false;
388
+ {
389
+ ReactCurrentDispatcher.current = previousDispatcher;
390
+ reenableLogs();
391
+ }
392
+ Error.prepareStackTrace = previousPrepareStackTrace;
393
+ }
394
+ var name = fn ? fn.displayName || fn.name : "";
395
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
396
+ {
397
+ if (typeof fn === "function") {
398
+ componentFrameCache.set(fn, syntheticFrame);
399
+ }
400
+ }
401
+ return syntheticFrame;
402
+ }
403
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
404
+ {
405
+ return describeNativeComponentFrame(fn, false);
406
+ }
407
+ }
408
+ function shouldConstruct(Component) {
409
+ var prototype = Component.prototype;
410
+ return !!(prototype && prototype.isReactComponent);
411
+ }
412
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
413
+ if (type == null) {
414
+ return "";
415
+ }
416
+ if (typeof type === "function") {
417
+ {
418
+ return describeNativeComponentFrame(type, shouldConstruct(type));
419
+ }
420
+ }
421
+ if (typeof type === "string") {
422
+ return describeBuiltInComponentFrame(type);
423
+ }
424
+ switch (type) {
425
+ case REACT_SUSPENSE_TYPE:
426
+ return describeBuiltInComponentFrame("Suspense");
427
+ case REACT_SUSPENSE_LIST_TYPE:
428
+ return describeBuiltInComponentFrame("SuspenseList");
429
+ }
430
+ if (typeof type === "object") {
431
+ switch (type.$$typeof) {
432
+ case REACT_FORWARD_REF_TYPE:
433
+ return describeFunctionComponentFrame(type.render);
434
+ case REACT_MEMO_TYPE:
435
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
436
+ case REACT_LAZY_TYPE: {
437
+ var lazyComponent = type;
438
+ var payload = lazyComponent._payload;
439
+ var init = lazyComponent._init;
440
+ try {
441
+ return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
442
+ } catch (x) {
443
+ }
444
+ }
445
+ }
446
+ }
447
+ return "";
448
+ }
449
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
450
+ var loggedTypeFailures = {};
451
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
452
+ function setCurrentlyValidatingElement(element) {
453
+ {
454
+ if (element) {
455
+ var owner = element._owner;
456
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
457
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
458
+ } else {
459
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
460
+ }
461
+ }
462
+ }
463
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
464
+ {
465
+ var has = Function.call.bind(hasOwnProperty);
466
+ for (var typeSpecName in typeSpecs) {
467
+ if (has(typeSpecs, typeSpecName)) {
468
+ var error$1 = void 0;
469
+ try {
470
+ if (typeof typeSpecs[typeSpecName] !== "function") {
471
+ var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
472
+ err.name = "Invariant Violation";
473
+ throw err;
474
+ }
475
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
476
+ } catch (ex) {
477
+ error$1 = ex;
478
+ }
479
+ if (error$1 && !(error$1 instanceof Error)) {
480
+ setCurrentlyValidatingElement(element);
481
+ error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
482
+ setCurrentlyValidatingElement(null);
483
+ }
484
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
485
+ loggedTypeFailures[error$1.message] = true;
486
+ setCurrentlyValidatingElement(element);
487
+ error("Failed %s type: %s", location, error$1.message);
488
+ setCurrentlyValidatingElement(null);
489
+ }
490
+ }
491
+ }
492
+ }
493
+ }
494
+ var isArrayImpl = Array.isArray;
495
+ function isArray(a) {
496
+ return isArrayImpl(a);
497
+ }
498
+ function typeName(value) {
499
+ {
500
+ var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
501
+ var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
502
+ return type;
503
+ }
504
+ }
505
+ function willCoercionThrow(value) {
506
+ {
507
+ try {
508
+ testStringCoercion(value);
509
+ return false;
510
+ } catch (e) {
511
+ return true;
512
+ }
513
+ }
514
+ }
515
+ function testStringCoercion(value) {
516
+ return "" + value;
517
+ }
518
+ function checkKeyStringCoercion(value) {
519
+ {
520
+ if (willCoercionThrow(value)) {
521
+ error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
522
+ return testStringCoercion(value);
523
+ }
524
+ }
525
+ }
526
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
527
+ var RESERVED_PROPS = {
528
+ key: true,
529
+ ref: true,
530
+ __self: true,
531
+ __source: true
532
+ };
533
+ var specialPropKeyWarningShown;
534
+ var specialPropRefWarningShown;
535
+ function hasValidRef(config) {
536
+ {
537
+ if (hasOwnProperty.call(config, "ref")) {
538
+ var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
539
+ if (getter && getter.isReactWarning) {
540
+ return false;
541
+ }
542
+ }
543
+ }
544
+ return config.ref !== void 0;
545
+ }
546
+ function hasValidKey(config) {
547
+ {
548
+ if (hasOwnProperty.call(config, "key")) {
549
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
550
+ if (getter && getter.isReactWarning) {
551
+ return false;
552
+ }
553
+ }
554
+ }
555
+ return config.key !== void 0;
556
+ }
557
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
558
+ {
559
+ if (typeof config.ref === "string" && ReactCurrentOwner.current && self) ;
560
+ }
561
+ }
562
+ function defineKeyPropWarningGetter(props, displayName) {
563
+ {
564
+ var warnAboutAccessingKey = function() {
565
+ if (!specialPropKeyWarningShown) {
566
+ specialPropKeyWarningShown = true;
567
+ error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
568
+ }
569
+ };
570
+ warnAboutAccessingKey.isReactWarning = true;
571
+ Object.defineProperty(props, "key", {
572
+ get: warnAboutAccessingKey,
573
+ configurable: true
574
+ });
575
+ }
576
+ }
577
+ function defineRefPropWarningGetter(props, displayName) {
578
+ {
579
+ var warnAboutAccessingRef = function() {
580
+ if (!specialPropRefWarningShown) {
581
+ specialPropRefWarningShown = true;
582
+ error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
583
+ }
584
+ };
585
+ warnAboutAccessingRef.isReactWarning = true;
586
+ Object.defineProperty(props, "ref", {
587
+ get: warnAboutAccessingRef,
588
+ configurable: true
589
+ });
590
+ }
591
+ }
592
+ var ReactElement = function(type, key, ref, self, source, owner, props) {
593
+ var element = {
594
+ // This tag allows us to uniquely identify this as a React Element
595
+ $$typeof: REACT_ELEMENT_TYPE,
596
+ // Built-in properties that belong on the element
597
+ type,
598
+ key,
599
+ ref,
600
+ props,
601
+ // Record the component responsible for creating this element.
602
+ _owner: owner
603
+ };
604
+ {
605
+ element._store = {};
606
+ Object.defineProperty(element._store, "validated", {
607
+ configurable: false,
608
+ enumerable: false,
609
+ writable: true,
610
+ value: false
611
+ });
612
+ Object.defineProperty(element, "_self", {
613
+ configurable: false,
614
+ enumerable: false,
615
+ writable: false,
616
+ value: self
617
+ });
618
+ Object.defineProperty(element, "_source", {
619
+ configurable: false,
620
+ enumerable: false,
621
+ writable: false,
622
+ value: source
623
+ });
624
+ if (Object.freeze) {
625
+ Object.freeze(element.props);
626
+ Object.freeze(element);
627
+ }
628
+ }
629
+ return element;
630
+ };
631
+ function jsxDEV(type, config, maybeKey, source, self) {
632
+ {
633
+ var propName;
634
+ var props = {};
635
+ var key = null;
636
+ var ref = null;
637
+ if (maybeKey !== void 0) {
638
+ {
639
+ checkKeyStringCoercion(maybeKey);
640
+ }
641
+ key = "" + maybeKey;
642
+ }
643
+ if (hasValidKey(config)) {
644
+ {
645
+ checkKeyStringCoercion(config.key);
646
+ }
647
+ key = "" + config.key;
648
+ }
649
+ if (hasValidRef(config)) {
650
+ ref = config.ref;
651
+ warnIfStringRefCannotBeAutoConverted(config, self);
652
+ }
653
+ for (propName in config) {
654
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
655
+ props[propName] = config[propName];
656
+ }
657
+ }
658
+ if (type && type.defaultProps) {
659
+ var defaultProps = type.defaultProps;
660
+ for (propName in defaultProps) {
661
+ if (props[propName] === void 0) {
662
+ props[propName] = defaultProps[propName];
663
+ }
664
+ }
665
+ }
666
+ if (key || ref) {
667
+ var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
668
+ if (key) {
669
+ defineKeyPropWarningGetter(props, displayName);
670
+ }
671
+ if (ref) {
672
+ defineRefPropWarningGetter(props, displayName);
673
+ }
674
+ }
675
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
676
+ }
677
+ }
678
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
679
+ var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
680
+ function setCurrentlyValidatingElement$1(element) {
681
+ {
682
+ if (element) {
683
+ var owner = element._owner;
684
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
685
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
686
+ } else {
687
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
688
+ }
689
+ }
690
+ }
691
+ var propTypesMisspellWarningShown;
692
+ {
693
+ propTypesMisspellWarningShown = false;
694
+ }
695
+ function isValidElement(object) {
696
+ {
697
+ return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
698
+ }
699
+ }
700
+ function getDeclarationErrorAddendum() {
701
+ {
702
+ if (ReactCurrentOwner$1.current) {
703
+ var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
704
+ if (name) {
705
+ return "\n\nCheck the render method of `" + name + "`.";
706
+ }
707
+ }
708
+ return "";
709
+ }
710
+ }
711
+ function getSourceInfoErrorAddendum(source) {
712
+ {
713
+ return "";
714
+ }
715
+ }
716
+ var ownerHasKeyUseWarning = {};
717
+ function getCurrentComponentErrorInfo(parentType) {
718
+ {
719
+ var info = getDeclarationErrorAddendum();
720
+ if (!info) {
721
+ var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
722
+ if (parentName) {
723
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
724
+ }
725
+ }
726
+ return info;
727
+ }
728
+ }
729
+ function validateExplicitKey(element, parentType) {
730
+ {
731
+ if (!element._store || element._store.validated || element.key != null) {
732
+ return;
733
+ }
734
+ element._store.validated = true;
735
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
736
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
737
+ return;
738
+ }
739
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
740
+ var childOwner = "";
741
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
742
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
743
+ }
744
+ setCurrentlyValidatingElement$1(element);
745
+ error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
746
+ setCurrentlyValidatingElement$1(null);
747
+ }
748
+ }
749
+ function validateChildKeys(node, parentType) {
750
+ {
751
+ if (typeof node !== "object") {
752
+ return;
753
+ }
754
+ if (isArray(node)) {
755
+ for (var i = 0; i < node.length; i++) {
756
+ var child = node[i];
757
+ if (isValidElement(child)) {
758
+ validateExplicitKey(child, parentType);
759
+ }
760
+ }
761
+ } else if (isValidElement(node)) {
762
+ if (node._store) {
763
+ node._store.validated = true;
764
+ }
765
+ } else if (node) {
766
+ var iteratorFn = getIteratorFn(node);
767
+ if (typeof iteratorFn === "function") {
768
+ if (iteratorFn !== node.entries) {
769
+ var iterator = iteratorFn.call(node);
770
+ var step;
771
+ while (!(step = iterator.next()).done) {
772
+ if (isValidElement(step.value)) {
773
+ validateExplicitKey(step.value, parentType);
774
+ }
775
+ }
776
+ }
777
+ }
778
+ }
779
+ }
780
+ }
781
+ function validatePropTypes(element) {
782
+ {
783
+ var type = element.type;
784
+ if (type === null || type === void 0 || typeof type === "string") {
785
+ return;
786
+ }
787
+ var propTypes;
788
+ if (typeof type === "function") {
789
+ propTypes = type.propTypes;
790
+ } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
791
+ // Inner props are checked in the reconciler.
792
+ type.$$typeof === REACT_MEMO_TYPE)) {
793
+ propTypes = type.propTypes;
794
+ } else {
795
+ return;
796
+ }
797
+ if (propTypes) {
798
+ var name = getComponentNameFromType(type);
799
+ checkPropTypes(propTypes, element.props, "prop", name, element);
800
+ } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
801
+ propTypesMisspellWarningShown = true;
802
+ var _name = getComponentNameFromType(type);
803
+ error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
804
+ }
805
+ if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
806
+ error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
807
+ }
808
+ }
809
+ }
810
+ function validateFragmentProps(fragment) {
811
+ {
812
+ var keys = Object.keys(fragment.props);
813
+ for (var i = 0; i < keys.length; i++) {
814
+ var key = keys[i];
815
+ if (key !== "children" && key !== "key") {
816
+ setCurrentlyValidatingElement$1(fragment);
817
+ error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
818
+ setCurrentlyValidatingElement$1(null);
819
+ break;
820
+ }
821
+ }
822
+ if (fragment.ref !== null) {
823
+ setCurrentlyValidatingElement$1(fragment);
824
+ error("Invalid attribute `ref` supplied to `React.Fragment`.");
825
+ setCurrentlyValidatingElement$1(null);
826
+ }
827
+ }
828
+ }
829
+ var didWarnAboutKeySpread = {};
830
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
831
+ {
832
+ var validType = isValidElementType(type);
833
+ if (!validType) {
834
+ var info = "";
835
+ if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
836
+ info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
837
+ }
838
+ var sourceInfo = getSourceInfoErrorAddendum();
839
+ if (sourceInfo) {
840
+ info += sourceInfo;
841
+ } else {
842
+ info += getDeclarationErrorAddendum();
843
+ }
844
+ var typeString;
845
+ if (type === null) {
846
+ typeString = "null";
847
+ } else if (isArray(type)) {
848
+ typeString = "array";
849
+ } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
850
+ typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
851
+ info = " Did you accidentally export a JSX literal instead of a component?";
852
+ } else {
853
+ typeString = typeof type;
854
+ }
855
+ error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
856
+ }
857
+ var element = jsxDEV(type, props, key, source, self);
858
+ if (element == null) {
859
+ return element;
860
+ }
861
+ if (validType) {
862
+ var children = props.children;
863
+ if (children !== void 0) {
864
+ if (isStaticChildren) {
865
+ if (isArray(children)) {
866
+ for (var i = 0; i < children.length; i++) {
867
+ validateChildKeys(children[i], type);
868
+ }
869
+ if (Object.freeze) {
870
+ Object.freeze(children);
871
+ }
872
+ } else {
873
+ error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
874
+ }
875
+ } else {
876
+ validateChildKeys(children, type);
877
+ }
878
+ }
879
+ }
880
+ {
881
+ if (hasOwnProperty.call(props, "key")) {
882
+ var componentName = getComponentNameFromType(type);
883
+ var keys = Object.keys(props).filter(function(k) {
884
+ return k !== "key";
885
+ });
886
+ var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
887
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
888
+ var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
889
+ error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
890
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
891
+ }
892
+ }
893
+ }
894
+ if (type === REACT_FRAGMENT_TYPE) {
895
+ validateFragmentProps(element);
896
+ } else {
897
+ validatePropTypes(element);
898
+ }
899
+ return element;
900
+ }
901
+ }
902
+ function jsxWithValidationStatic(type, props, key) {
903
+ {
904
+ return jsxWithValidation(type, props, key, true);
905
+ }
906
+ }
907
+ function jsxWithValidationDynamic(type, props, key) {
908
+ {
909
+ return jsxWithValidation(type, props, key, false);
910
+ }
911
+ }
912
+ var jsx = jsxWithValidationDynamic;
913
+ var jsxs = jsxWithValidationStatic;
914
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
915
+ reactJsxRuntime_development.jsx = jsx;
916
+ reactJsxRuntime_development.jsxs = jsxs;
917
+ })();
918
+ }
919
+ return reactJsxRuntime_development;
920
+ }
921
+ if (process.env.NODE_ENV === "production") {
922
+ jsxRuntime.exports = requireReactJsxRuntime_production_min();
923
+ } else {
924
+ jsxRuntime.exports = requireReactJsxRuntime_development();
925
+ }
926
+ var jsxRuntimeExports = jsxRuntime.exports;
927
+ const AuthContext = require$$0.createContext(
928
+ void 0
929
+ );
930
+ AuthContext.displayName = "AuthContext";
931
+ function normalizeError(error) {
932
+ if (isAuthError(error)) {
933
+ return error;
934
+ }
935
+ if (error instanceof Error) {
936
+ return {
937
+ code: "ERROR",
938
+ message: error.message,
939
+ statusCode: void 0
940
+ };
941
+ }
942
+ if (typeof error === "object" && error !== null && "status" in error && "statusText" in error) {
943
+ const fetchError = error;
944
+ return {
945
+ code: `HTTP_${fetchError.status}`,
946
+ message: fetchError.statusText || "Request failed",
947
+ statusCode: fetchError.status
948
+ };
949
+ }
950
+ if (typeof error === "object" && error !== null && "error" in error && typeof error.error === "object") {
951
+ const apiError = error.error;
952
+ return {
953
+ code: apiError.code || "API_ERROR",
954
+ message: apiError.message || "An error occurred",
955
+ statusCode: apiError.statusCode || void 0,
956
+ details: apiError.details
957
+ };
958
+ }
959
+ if (typeof error === "object" && error !== null && "message" in error) {
960
+ const objError = error;
961
+ return {
962
+ code: objError.code || "ERROR",
963
+ message: typeof objError.message === "string" ? objError.message : "An unknown error occurred"
964
+ };
965
+ }
966
+ if (typeof error === "string") {
967
+ return {
968
+ code: "ERROR",
969
+ message: error
970
+ };
971
+ }
972
+ return {
973
+ code: "UNKNOWN_ERROR",
974
+ message: "An unknown error occurred"
975
+ };
976
+ }
977
+ function isAuthError(error) {
978
+ return typeof error === "object" && error !== null && "code" in error && "message" in error && typeof error.code === "string" && typeof error.message === "string";
979
+ }
980
+ const DEFAULT_ENDPOINTS = {
981
+ login: "/auth/login",
982
+ register: "/auth/register",
983
+ logout: "/auth/logout",
984
+ me: "/auth/me",
985
+ refresh: "/auth/refresh",
986
+ forgotPassword: "/auth/forgot-password",
987
+ resetPassword: "/auth/reset-password",
988
+ verifyEmail: "/auth/verify-email"
989
+ };
990
+ const defaultAdapter = async (url, options) => {
991
+ const response = await fetch(url, options);
992
+ return response;
993
+ };
994
+ function createAuthClient(config = {}) {
995
+ const {
996
+ baseURL = "",
997
+ endpoints = {},
998
+ headers = {},
999
+ credentials = "include",
1000
+ adapter = defaultAdapter
1001
+ } = config;
1002
+ const finalEndpoints = { ...DEFAULT_ENDPOINTS, ...endpoints };
1003
+ async function request(method, endpoint, data) {
1004
+ const url = `${baseURL}${endpoint}`;
1005
+ const options = {
1006
+ method,
1007
+ credentials,
1008
+ headers: {
1009
+ "Content-Type": "application/json",
1010
+ ...headers
1011
+ }
1012
+ };
1013
+ if (data) {
1014
+ options.body = JSON.stringify(data);
1015
+ }
1016
+ try {
1017
+ const response = await adapter(url, options);
1018
+ if (!response.ok) {
1019
+ let errorData = null;
1020
+ try {
1021
+ errorData = await response.json();
1022
+ } catch {
1023
+ errorData = {
1024
+ error: {
1025
+ message: response.statusText,
1026
+ statusCode: response.status
1027
+ }
1028
+ };
1029
+ }
1030
+ throw errorData;
1031
+ }
1032
+ const contentType = response.headers.get("content-type");
1033
+ if (contentType && contentType.includes("application/json")) {
1034
+ return await response.json();
1035
+ }
1036
+ return {};
1037
+ } catch (error) {
1038
+ throw normalizeError(error);
1039
+ }
1040
+ }
1041
+ return {
1042
+ /**
1043
+ * Login with email and password
1044
+ */
1045
+ async login(email, password, rememberMe) {
1046
+ const response = await request(
1047
+ "POST",
1048
+ finalEndpoints.login,
1049
+ { email, password, rememberMe }
1050
+ );
1051
+ return response;
1052
+ },
1053
+ /**
1054
+ * Register a new account
1055
+ */
1056
+ async register(payload) {
1057
+ const response = await request(
1058
+ "POST",
1059
+ finalEndpoints.register,
1060
+ payload
1061
+ );
1062
+ return response;
1063
+ },
1064
+ /**
1065
+ * Logout the user
1066
+ */
1067
+ async logout() {
1068
+ await request("POST", finalEndpoints.logout);
1069
+ },
1070
+ /**
1071
+ * Get current user
1072
+ */
1073
+ async me() {
1074
+ const response = await request(
1075
+ "GET",
1076
+ finalEndpoints.me
1077
+ );
1078
+ return response;
1079
+ },
1080
+ /**
1081
+ * Refresh the authentication session
1082
+ */
1083
+ async refresh() {
1084
+ const response = await request(
1085
+ "POST",
1086
+ finalEndpoints.refresh
1087
+ );
1088
+ return response;
1089
+ },
1090
+ /**
1091
+ * Request a password reset
1092
+ */
1093
+ async forgotPassword(email) {
1094
+ await request("POST", finalEndpoints.forgotPassword, { email });
1095
+ },
1096
+ /**
1097
+ * Reset password with token
1098
+ */
1099
+ async resetPassword(token, password, confirmPassword) {
1100
+ await request("POST", finalEndpoints.resetPassword, {
1101
+ token,
1102
+ password,
1103
+ confirmPassword
1104
+ });
1105
+ },
1106
+ /**
1107
+ * Verify email with token
1108
+ */
1109
+ async verifyEmail(token, email) {
1110
+ await request("POST", finalEndpoints.verifyEmail, { token, email });
1111
+ },
1112
+ /**
1113
+ * Set custom headers for subsequent requests
1114
+ */
1115
+ setHeaders(newHeaders) {
1116
+ Object.assign(headers, newHeaders);
1117
+ },
1118
+ /**
1119
+ * Get current endpoints configuration
1120
+ */
1121
+ getEndpoints() {
1122
+ return finalEndpoints;
1123
+ }
1124
+ };
1125
+ }
1126
+ const initialState = {
1127
+ user: null,
1128
+ isAuthenticated: false,
1129
+ isLoading: false,
1130
+ error: null
1131
+ };
1132
+ function authReducer(state, action) {
1133
+ switch (action.type) {
1134
+ case "SET_LOADING":
1135
+ return { ...state, isLoading: action.payload };
1136
+ case "SET_ERROR":
1137
+ return { ...state, error: action.payload, isLoading: false };
1138
+ case "SET_USER":
1139
+ return {
1140
+ ...state,
1141
+ user: action.payload,
1142
+ isAuthenticated: action.payload !== null,
1143
+ error: null,
1144
+ isLoading: false
1145
+ };
1146
+ case "LOGOUT":
1147
+ return initialState;
1148
+ default:
1149
+ return state;
1150
+ }
1151
+ }
1152
+ const AuthProvider = ({
1153
+ children,
1154
+ baseURL = "",
1155
+ endpoints = {},
1156
+ onAuthError,
1157
+ autoRefresh = true,
1158
+ refreshInterval = 5 * 60 * 1e3
1159
+ // 5 minutes
1160
+ }) => {
1161
+ const [state, dispatch] = require$$0.useReducer(authReducer, initialState);
1162
+ const clientRef = require$$0.useRef(
1163
+ createAuthClient({
1164
+ baseURL,
1165
+ endpoints,
1166
+ credentials: "include"
1167
+ })
1168
+ );
1169
+ const client = clientRef.current;
1170
+ const handleError = require$$0.useCallback(
1171
+ (error) => {
1172
+ dispatch({ type: "SET_ERROR", payload: error });
1173
+ onAuthError?.(error);
1174
+ },
1175
+ [onAuthError]
1176
+ );
1177
+ const restoreSession = require$$0.useCallback(async () => {
1178
+ dispatch({ type: "SET_LOADING", payload: true });
1179
+ try {
1180
+ const response = await client.me();
1181
+ if (response.user) {
1182
+ dispatch({ type: "SET_USER", payload: response.user });
1183
+ } else {
1184
+ dispatch({ type: "LOGOUT" });
1185
+ }
1186
+ } catch (_error) {
1187
+ dispatch({ type: "SET_LOADING", payload: false });
1188
+ }
1189
+ }, [client]);
1190
+ const refreshSession = require$$0.useCallback(async () => {
1191
+ try {
1192
+ const response = await client.refresh();
1193
+ if (response.user) {
1194
+ dispatch({ type: "SET_USER", payload: response.user });
1195
+ }
1196
+ } catch (error) {
1197
+ const authError = normalizeError(error);
1198
+ handleError(authError);
1199
+ }
1200
+ }, [client, handleError]);
1201
+ const login = require$$0.useCallback(
1202
+ async (payload) => {
1203
+ dispatch({ type: "SET_LOADING", payload: true });
1204
+ try {
1205
+ const response = await client.login(payload.email, payload.password);
1206
+ if (!response.user) {
1207
+ throw new Error("No user data in response");
1208
+ }
1209
+ dispatch({ type: "SET_USER", payload: response.user });
1210
+ return response.user;
1211
+ } catch (error) {
1212
+ const authError = normalizeError(error);
1213
+ handleError(authError);
1214
+ throw authError;
1215
+ }
1216
+ },
1217
+ [client, handleError]
1218
+ );
1219
+ const register = require$$0.useCallback(
1220
+ async (payload) => {
1221
+ dispatch({ type: "SET_LOADING", payload: true });
1222
+ try {
1223
+ const response = await client.register(payload);
1224
+ if (!response.user) {
1225
+ throw new Error("No user data in response");
1226
+ }
1227
+ dispatch({ type: "SET_USER", payload: response.user });
1228
+ return response.user;
1229
+ } catch (error) {
1230
+ const authError = normalizeError(error);
1231
+ handleError(authError);
1232
+ throw authError;
1233
+ }
1234
+ },
1235
+ [client, handleError]
1236
+ );
1237
+ const logout = require$$0.useCallback(async () => {
1238
+ dispatch({ type: "SET_LOADING", payload: true });
1239
+ try {
1240
+ await client.logout();
1241
+ } catch (error) {
1242
+ console.error("Logout error:", error);
1243
+ } finally {
1244
+ dispatch({ type: "LOGOUT" });
1245
+ }
1246
+ }, [client]);
1247
+ const forgotPassword = require$$0.useCallback(
1248
+ async (payload) => {
1249
+ dispatch({ type: "SET_LOADING", payload: true });
1250
+ try {
1251
+ await client.forgotPassword(payload.email);
1252
+ dispatch({ type: "SET_LOADING", payload: false });
1253
+ } catch (error) {
1254
+ const authError = normalizeError(error);
1255
+ handleError(authError);
1256
+ throw authError;
1257
+ }
1258
+ },
1259
+ [client, handleError]
1260
+ );
1261
+ const resetPassword = require$$0.useCallback(
1262
+ async (payload) => {
1263
+ dispatch({ type: "SET_LOADING", payload: true });
1264
+ try {
1265
+ await client.resetPassword(
1266
+ payload.token,
1267
+ payload.password,
1268
+ payload.confirmPassword
1269
+ );
1270
+ dispatch({ type: "SET_LOADING", payload: false });
1271
+ } catch (error) {
1272
+ const authError = normalizeError(error);
1273
+ handleError(authError);
1274
+ throw authError;
1275
+ }
1276
+ },
1277
+ [client, handleError]
1278
+ );
1279
+ const verifyEmail = require$$0.useCallback(
1280
+ async (payload) => {
1281
+ dispatch({ type: "SET_LOADING", payload: true });
1282
+ try {
1283
+ await client.verifyEmail(payload.token, payload.email);
1284
+ dispatch({ type: "SET_LOADING", payload: false });
1285
+ } catch (error) {
1286
+ const authError = normalizeError(error);
1287
+ handleError(authError);
1288
+ throw authError;
1289
+ }
1290
+ },
1291
+ [client, handleError]
1292
+ );
1293
+ const setUser = require$$0.useCallback((user) => {
1294
+ dispatch({ type: "SET_USER", payload: user });
1295
+ }, []);
1296
+ require$$0.useEffect(() => {
1297
+ restoreSession();
1298
+ }, [restoreSession]);
1299
+ require$$0.useEffect(() => {
1300
+ if (!autoRefresh || !state.isAuthenticated) {
1301
+ return;
1302
+ }
1303
+ const interval = setInterval(() => {
1304
+ refreshSession();
1305
+ }, refreshInterval);
1306
+ return () => clearInterval(interval);
1307
+ }, [autoRefresh, state.isAuthenticated, refreshSession, refreshInterval]);
1308
+ const value = {
1309
+ ...state,
1310
+ login,
1311
+ register,
1312
+ logout,
1313
+ forgotPassword,
1314
+ resetPassword,
1315
+ verifyEmail,
1316
+ refreshSession,
1317
+ restoreSession,
1318
+ setUser
1319
+ };
1320
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(AuthContext.Provider, { value, children });
1321
+ };
1322
+ function useAuth() {
1323
+ const context = require$$0.useContext(AuthContext);
1324
+ if (!context) {
1325
+ throw new Error("useAuth must be used within an AuthProvider");
1326
+ }
1327
+ return context;
1328
+ }
1329
+ const LoginForm = ({
1330
+ className = "",
1331
+ labels = {},
1332
+ placeholders = {},
1333
+ submitButtonText = "Login",
1334
+ onSuccess,
1335
+ onError
1336
+ }) => {
1337
+ const { login, isLoading: authLoading, error: authError } = useAuth();
1338
+ const [formError, setFormError] = require$$0.useState("");
1339
+ const [email, setEmail] = require$$0.useState("");
1340
+ const [password, setPassword] = require$$0.useState("");
1341
+ const [rememberMe, setRememberMe] = require$$0.useState(false);
1342
+ const isLoading = authLoading;
1343
+ const error = formError || authError?.message;
1344
+ const handleSubmit = async (e) => {
1345
+ e.preventDefault();
1346
+ setFormError("");
1347
+ if (!email || !password) {
1348
+ setFormError("Email and password are required");
1349
+ return;
1350
+ }
1351
+ try {
1352
+ const user = await login({ email, password, rememberMe });
1353
+ onSuccess?.(user);
1354
+ } catch (err) {
1355
+ const errorMsg = err instanceof Error ? err.message : "Login failed";
1356
+ setFormError(errorMsg);
1357
+ onError?.({
1358
+ code: "LOGIN_ERROR",
1359
+ message: errorMsg
1360
+ });
1361
+ }
1362
+ };
1363
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
1364
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1365
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
1366
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1367
+ "input",
1368
+ {
1369
+ id: "email",
1370
+ type: "email",
1371
+ value: email,
1372
+ onChange: (e) => setEmail(e.target.value),
1373
+ placeholder: placeholders.email || "your@email.com",
1374
+ disabled: isLoading,
1375
+ className: "auth-form-input",
1376
+ required: true
1377
+ }
1378
+ )
1379
+ ] }),
1380
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1381
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "Password" }),
1382
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1383
+ "input",
1384
+ {
1385
+ id: "password",
1386
+ type: "password",
1387
+ value: password,
1388
+ onChange: (e) => setPassword(e.target.value),
1389
+ placeholder: placeholders.password || "••••••••",
1390
+ disabled: isLoading,
1391
+ className: "auth-form-input",
1392
+ required: true
1393
+ }
1394
+ )
1395
+ ] }),
1396
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group auth-form-checkbox", children: [
1397
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1398
+ "input",
1399
+ {
1400
+ id: "rememberMe",
1401
+ type: "checkbox",
1402
+ checked: rememberMe,
1403
+ onChange: (e) => setRememberMe(e.target.checked),
1404
+ disabled: isLoading,
1405
+ className: "auth-form-input"
1406
+ }
1407
+ ),
1408
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "rememberMe", className: "auth-form-label", children: labels.rememberMe || "Remember me" })
1409
+ ] }),
1410
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
1411
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1412
+ "button",
1413
+ {
1414
+ type: "submit",
1415
+ disabled: isLoading,
1416
+ className: "auth-form-button auth-form-button-primary",
1417
+ children: isLoading ? "Loading..." : submitButtonText
1418
+ }
1419
+ )
1420
+ ] });
1421
+ };
1422
+ LoginForm.displayName = "LoginForm";
1423
+ const RegisterForm = ({
1424
+ className = "",
1425
+ labels = {},
1426
+ placeholders = {},
1427
+ submitButtonText = "Register",
1428
+ onSuccess,
1429
+ onError
1430
+ }) => {
1431
+ const { register, isLoading: authLoading, error: authError } = useAuth();
1432
+ const [formError, setFormError] = require$$0.useState("");
1433
+ const [name, setName] = require$$0.useState("");
1434
+ const [email, setEmail] = require$$0.useState("");
1435
+ const [password, setPassword] = require$$0.useState("");
1436
+ const [confirmPassword, setConfirmPassword] = require$$0.useState("");
1437
+ const isLoading = authLoading;
1438
+ const error = formError || authError?.message;
1439
+ const handleSubmit = async (e) => {
1440
+ e.preventDefault();
1441
+ setFormError("");
1442
+ if (!name || !email || !password || !confirmPassword) {
1443
+ setFormError("All fields are required");
1444
+ return;
1445
+ }
1446
+ if (password !== confirmPassword) {
1447
+ setFormError("Passwords do not match");
1448
+ return;
1449
+ }
1450
+ if (password.length < 8) {
1451
+ setFormError("Password must be at least 8 characters");
1452
+ return;
1453
+ }
1454
+ try {
1455
+ const user = await register({
1456
+ name,
1457
+ email,
1458
+ password,
1459
+ confirmPassword
1460
+ });
1461
+ onSuccess?.(user);
1462
+ } catch (err) {
1463
+ const errorMsg = err instanceof Error ? err.message : "Registration failed";
1464
+ setFormError(errorMsg);
1465
+ onError?.({
1466
+ code: "REGISTER_ERROR",
1467
+ message: errorMsg
1468
+ });
1469
+ }
1470
+ };
1471
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
1472
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1473
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "name", className: "auth-form-label", children: labels.name || "Full Name" }),
1474
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1475
+ "input",
1476
+ {
1477
+ id: "name",
1478
+ type: "text",
1479
+ value: name,
1480
+ onChange: (e) => setName(e.target.value),
1481
+ placeholder: placeholders.name || "John Doe",
1482
+ disabled: isLoading,
1483
+ className: "auth-form-input",
1484
+ required: true
1485
+ }
1486
+ )
1487
+ ] }),
1488
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1489
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
1490
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1491
+ "input",
1492
+ {
1493
+ id: "email",
1494
+ type: "email",
1495
+ value: email,
1496
+ onChange: (e) => setEmail(e.target.value),
1497
+ placeholder: placeholders.email || "your@email.com",
1498
+ disabled: isLoading,
1499
+ className: "auth-form-input",
1500
+ required: true
1501
+ }
1502
+ )
1503
+ ] }),
1504
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1505
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "Password" }),
1506
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1507
+ "input",
1508
+ {
1509
+ id: "password",
1510
+ type: "password",
1511
+ value: password,
1512
+ onChange: (e) => setPassword(e.target.value),
1513
+ placeholder: placeholders.password || "••••••••",
1514
+ disabled: isLoading,
1515
+ className: "auth-form-input",
1516
+ required: true
1517
+ }
1518
+ )
1519
+ ] }),
1520
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1521
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "confirmPassword", className: "auth-form-label", children: labels.confirmPassword || "Confirm Password" }),
1522
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1523
+ "input",
1524
+ {
1525
+ id: "confirmPassword",
1526
+ type: "password",
1527
+ value: confirmPassword,
1528
+ onChange: (e) => setConfirmPassword(e.target.value),
1529
+ placeholder: placeholders.confirmPassword || "••••••••",
1530
+ disabled: isLoading,
1531
+ className: "auth-form-input",
1532
+ required: true
1533
+ }
1534
+ )
1535
+ ] }),
1536
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
1537
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1538
+ "button",
1539
+ {
1540
+ type: "submit",
1541
+ disabled: isLoading,
1542
+ className: "auth-form-button auth-form-button-primary",
1543
+ children: isLoading ? "Loading..." : submitButtonText
1544
+ }
1545
+ )
1546
+ ] });
1547
+ };
1548
+ RegisterForm.displayName = "RegisterForm";
1549
+ const ForgotPasswordForm = ({
1550
+ className = "",
1551
+ labels = {},
1552
+ placeholders = {},
1553
+ submitButtonText = "Send Reset Link",
1554
+ onSuccess,
1555
+ onError
1556
+ }) => {
1557
+ const {
1558
+ forgotPassword,
1559
+ isLoading: authLoading,
1560
+ error: authError
1561
+ } = useAuth();
1562
+ const [formError, setFormError] = require$$0.useState("");
1563
+ const [email, setEmail] = require$$0.useState("");
1564
+ const [successMessage, setSuccessMessage] = require$$0.useState("");
1565
+ const isLoading = authLoading;
1566
+ const error = formError || authError?.message;
1567
+ const handleSubmit = async (e) => {
1568
+ e.preventDefault();
1569
+ setFormError("");
1570
+ setSuccessMessage("");
1571
+ if (!email) {
1572
+ setFormError("Email is required");
1573
+ return;
1574
+ }
1575
+ try {
1576
+ await forgotPassword({ email });
1577
+ setSuccessMessage("Password reset link has been sent to your email");
1578
+ setEmail("");
1579
+ onSuccess?.();
1580
+ } catch (err) {
1581
+ const errorMsg = err instanceof Error ? err.message : "Request failed";
1582
+ setFormError(errorMsg);
1583
+ onError?.({
1584
+ code: "FORGOT_PASSWORD_ERROR",
1585
+ message: errorMsg
1586
+ });
1587
+ }
1588
+ };
1589
+ if (successMessage) {
1590
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
1591
+ }
1592
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
1593
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1594
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
1595
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1596
+ "input",
1597
+ {
1598
+ id: "email",
1599
+ type: "email",
1600
+ value: email,
1601
+ onChange: (e) => setEmail(e.target.value),
1602
+ placeholder: placeholders.email || "your@email.com",
1603
+ disabled: isLoading,
1604
+ className: "auth-form-input",
1605
+ required: true
1606
+ }
1607
+ )
1608
+ ] }),
1609
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
1610
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1611
+ "button",
1612
+ {
1613
+ type: "submit",
1614
+ disabled: isLoading,
1615
+ className: "auth-form-button auth-form-button-primary",
1616
+ children: isLoading ? "Loading..." : submitButtonText
1617
+ }
1618
+ )
1619
+ ] });
1620
+ };
1621
+ ForgotPasswordForm.displayName = "ForgotPasswordForm";
1622
+ const ResetPasswordForm = ({
1623
+ token,
1624
+ className = "",
1625
+ labels = {},
1626
+ placeholders = {},
1627
+ submitButtonText = "Reset Password",
1628
+ onSuccess,
1629
+ onError
1630
+ }) => {
1631
+ const {
1632
+ resetPassword,
1633
+ isLoading: authLoading,
1634
+ error: authError
1635
+ } = useAuth();
1636
+ const [formError, setFormError] = require$$0.useState("");
1637
+ const [password, setPassword] = require$$0.useState("");
1638
+ const [confirmPassword, setConfirmPassword] = require$$0.useState("");
1639
+ const [successMessage, setSuccessMessage] = require$$0.useState("");
1640
+ const isLoading = authLoading;
1641
+ const error = formError || authError?.message;
1642
+ const handleSubmit = async (e) => {
1643
+ e.preventDefault();
1644
+ setFormError("");
1645
+ setSuccessMessage("");
1646
+ if (!password || !confirmPassword) {
1647
+ setFormError("Both password fields are required");
1648
+ return;
1649
+ }
1650
+ if (password !== confirmPassword) {
1651
+ setFormError("Passwords do not match");
1652
+ return;
1653
+ }
1654
+ if (password.length < 8) {
1655
+ setFormError("Password must be at least 8 characters");
1656
+ return;
1657
+ }
1658
+ try {
1659
+ await resetPassword({ token, password, confirmPassword });
1660
+ setSuccessMessage("Password has been reset successfully");
1661
+ setPassword("");
1662
+ setConfirmPassword("");
1663
+ onSuccess?.();
1664
+ } catch (err) {
1665
+ const errorMsg = err instanceof Error ? err.message : "Reset failed";
1666
+ setFormError(errorMsg);
1667
+ onError?.({
1668
+ code: "RESET_PASSWORD_ERROR",
1669
+ message: errorMsg
1670
+ });
1671
+ }
1672
+ };
1673
+ if (successMessage) {
1674
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
1675
+ }
1676
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
1677
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1678
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "New Password" }),
1679
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1680
+ "input",
1681
+ {
1682
+ id: "password",
1683
+ type: "password",
1684
+ value: password,
1685
+ onChange: (e) => setPassword(e.target.value),
1686
+ placeholder: placeholders.password || "••••••••",
1687
+ disabled: isLoading,
1688
+ className: "auth-form-input",
1689
+ required: true
1690
+ }
1691
+ )
1692
+ ] }),
1693
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1694
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "confirmPassword", className: "auth-form-label", children: labels.confirmPassword || "Confirm Password" }),
1695
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1696
+ "input",
1697
+ {
1698
+ id: "confirmPassword",
1699
+ type: "password",
1700
+ value: confirmPassword,
1701
+ onChange: (e) => setConfirmPassword(e.target.value),
1702
+ placeholder: placeholders.confirmPassword || "••••••••",
1703
+ disabled: isLoading,
1704
+ className: "auth-form-input",
1705
+ required: true
1706
+ }
1707
+ )
1708
+ ] }),
1709
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
1710
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1711
+ "button",
1712
+ {
1713
+ type: "submit",
1714
+ disabled: isLoading,
1715
+ className: "auth-form-button auth-form-button-primary",
1716
+ children: isLoading ? "Loading..." : submitButtonText
1717
+ }
1718
+ )
1719
+ ] });
1720
+ };
1721
+ ResetPasswordForm.displayName = "ResetPasswordForm";
1722
+ const VerifyEmailForm = ({
1723
+ token: initialToken,
1724
+ email: initialEmail,
1725
+ className = "",
1726
+ labels = {},
1727
+ placeholders = {},
1728
+ submitButtonText = "Verify Email",
1729
+ onSuccess,
1730
+ onError
1731
+ }) => {
1732
+ const {
1733
+ verifyEmail,
1734
+ isLoading: authLoading,
1735
+ error: authError
1736
+ } = useAuth();
1737
+ const [formError, setFormError] = require$$0.useState("");
1738
+ const [email, setEmail] = require$$0.useState(initialEmail || "");
1739
+ const [token, setToken] = require$$0.useState(initialToken || "");
1740
+ const [successMessage, setSuccessMessage] = require$$0.useState("");
1741
+ const isLoading = authLoading;
1742
+ const error = formError || authError?.message;
1743
+ require$$0.useEffect(() => {
1744
+ if (token && email && !successMessage && !error) {
1745
+ handleSubmit({ preventDefault: () => {
1746
+ } });
1747
+ }
1748
+ }, [token, email]);
1749
+ const handleSubmit = async (e) => {
1750
+ e.preventDefault();
1751
+ setFormError("");
1752
+ setSuccessMessage("");
1753
+ if (!token) {
1754
+ setFormError("Verification token is required");
1755
+ return;
1756
+ }
1757
+ if (!email) {
1758
+ setFormError("Email is required");
1759
+ return;
1760
+ }
1761
+ try {
1762
+ await verifyEmail({ token, email });
1763
+ setSuccessMessage("Email has been verified successfully");
1764
+ onSuccess?.();
1765
+ } catch (err) {
1766
+ const errorMsg = err instanceof Error ? err.message : "Verification failed";
1767
+ setFormError(errorMsg);
1768
+ onError?.({
1769
+ code: "VERIFY_EMAIL_ERROR",
1770
+ message: errorMsg
1771
+ });
1772
+ }
1773
+ };
1774
+ if (successMessage) {
1775
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
1776
+ }
1777
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
1778
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1779
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
1780
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1781
+ "input",
1782
+ {
1783
+ id: "email",
1784
+ type: "email",
1785
+ value: email,
1786
+ onChange: (e) => setEmail(e.target.value),
1787
+ placeholder: placeholders.email || "your@email.com",
1788
+ disabled: isLoading,
1789
+ className: "auth-form-input",
1790
+ required: true
1791
+ }
1792
+ )
1793
+ ] }),
1794
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
1795
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "token", className: "auth-form-label", children: labels.token || "Verification Code" }),
1796
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1797
+ "input",
1798
+ {
1799
+ id: "token",
1800
+ type: "text",
1801
+ value: token,
1802
+ onChange: (e) => setToken(e.target.value),
1803
+ placeholder: placeholders.token || "Enter verification code",
1804
+ disabled: isLoading,
1805
+ className: "auth-form-input",
1806
+ required: true
1807
+ }
1808
+ )
1809
+ ] }),
1810
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
1811
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1812
+ "button",
1813
+ {
1814
+ type: "submit",
1815
+ disabled: isLoading,
1816
+ className: "auth-form-button auth-form-button-primary",
1817
+ children: isLoading ? "Loading..." : submitButtonText
1818
+ }
1819
+ )
1820
+ ] });
1821
+ };
1822
+ VerifyEmailForm.displayName = "VerifyEmailForm";
1823
+ const ProtectedRoute = ({
1824
+ children,
1825
+ redirectTo = "/login",
1826
+ fallback,
1827
+ roles,
1828
+ permissions
1829
+ }) => {
1830
+ const { isAuthenticated, isLoading, user } = useAuth();
1831
+ if (isLoading) {
1832
+ return fallback || /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-loading", children: "Loading..." });
1833
+ }
1834
+ if (!isAuthenticated) {
1835
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(reactRouterDom.Navigate, { to: redirectTo, replace: true });
1836
+ }
1837
+ if (roles && roles.length > 0) {
1838
+ const hasRole = user?.roles?.some((role) => roles.includes(role));
1839
+ if (!hasRole) {
1840
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-forbidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "You do not have permission to access this page." }) });
1841
+ }
1842
+ }
1843
+ if (permissions && permissions.length > 0) {
1844
+ const hasPermission = user?.permissions?.some(
1845
+ (permission) => permissions.includes(permission)
1846
+ );
1847
+ if (!hasPermission) {
1848
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-forbidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "You do not have permission to access this page." }) });
1849
+ }
1850
+ }
1851
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children });
1852
+ };
1853
+ ProtectedRoute.displayName = "ProtectedRoute";
1854
+ exports.AuthContext = AuthContext;
1855
+ exports.AuthProvider = AuthProvider;
1856
+ exports.ForgotPasswordForm = ForgotPasswordForm;
1857
+ exports.LoginForm = LoginForm;
1858
+ exports.ProtectedRoute = ProtectedRoute;
1859
+ exports.RegisterForm = RegisterForm;
1860
+ exports.ResetPasswordForm = ResetPasswordForm;
1861
+ exports.VerifyEmailForm = VerifyEmailForm;
1862
+ exports.createAuthClient = createAuthClient;
1863
+ exports.normalizeError = normalizeError;
1864
+ exports.useAuth = useAuth;
1865
+ //# sourceMappingURL=index.cjs.js.map