@qidcloud/sdk 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var axios = require('axios');
6
6
  var socket_ioClient = require('socket.io-client');
7
+ var React = require('react');
7
8
  var qrcode_react = require('qrcode.react');
8
9
 
9
10
  class AuthModule {
@@ -18,8 +19,13 @@ class AuthModule {
18
19
  async createSession() {
19
20
  const resp = await this.sdk.api.post('/api/initiate-generic');
20
21
  const { sessionId, nonce } = resp.data;
21
- // Construct QR data
22
- const qrData = `qid: handshake:${sessionId}:${nonce} `;
22
+ // Construct QR data (JSON format for mobile app)
23
+ const qrData = JSON.stringify({
24
+ sessionId,
25
+ nonce,
26
+ action: 'login-handshake',
27
+ timestamp: Date.now()
28
+ });
23
29
  return {
24
30
  sessionId,
25
31
  qrData,
@@ -48,6 +54,24 @@ class AuthModule {
48
54
  onDenied(data.message || 'Authorization denied');
49
55
  });
50
56
  }
57
+ /**
58
+ * Terminate the session on the server
59
+ */
60
+ async logout(token) {
61
+ if (!token)
62
+ return;
63
+ try {
64
+ await this.sdk.api.post('/api/logout', {}, {
65
+ headers: { 'Authorization': `Bearer ${token}` }
66
+ });
67
+ }
68
+ catch (e) {
69
+ console.warn('Logout failed or session already expired');
70
+ }
71
+ finally {
72
+ this.disconnect();
73
+ }
74
+ }
51
75
  /**
52
76
  * Stop listening and disconnect socket
53
77
  */
@@ -66,7 +90,14 @@ class AuthModule {
66
90
  'Authorization': `Bearer ${token}`
67
91
  }
68
92
  });
69
- return resp.data;
93
+ const data = resp.data;
94
+ return {
95
+ userId: data.regUserId,
96
+ regUserId: data.regUserId,
97
+ username: data.username,
98
+ email: data.email,
99
+ role: data.role
100
+ };
70
101
  }
71
102
  }
72
103
 
@@ -326,1945 +357,130 @@ class LogsModule {
326
357
  }
327
358
  }
328
359
 
329
- function getDefaultExportFromCjs (x) {
330
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
331
- }
332
-
333
- var react = {exports: {}};
334
-
335
- var react_production = {};
336
-
337
- /**
338
- * @license React
339
- * react.production.js
340
- *
341
- * Copyright (c) Meta Platforms, Inc. and affiliates.
342
- *
343
- * This source code is licensed under the MIT license found in the
344
- * LICENSE file in the root directory of this source tree.
345
- */
346
-
347
- var hasRequiredReact_production;
348
-
349
- function requireReact_production () {
350
- if (hasRequiredReact_production) return react_production;
351
- hasRequiredReact_production = 1;
352
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
353
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
354
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
355
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
356
- REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
357
- REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
358
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
359
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
360
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
361
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
362
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
363
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
364
- MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
365
- function getIteratorFn(maybeIterable) {
366
- if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
367
- maybeIterable =
368
- (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
369
- maybeIterable["@@iterator"];
370
- return "function" === typeof maybeIterable ? maybeIterable : null;
371
- }
372
- var ReactNoopUpdateQueue = {
373
- isMounted: function () {
374
- return false;
375
- },
376
- enqueueForceUpdate: function () {},
377
- enqueueReplaceState: function () {},
378
- enqueueSetState: function () {}
379
- },
380
- assign = Object.assign,
381
- emptyObject = {};
382
- function Component(props, context, updater) {
383
- this.props = props;
384
- this.context = context;
385
- this.refs = emptyObject;
386
- this.updater = updater || ReactNoopUpdateQueue;
387
- }
388
- Component.prototype.isReactComponent = {};
389
- Component.prototype.setState = function (partialState, callback) {
390
- if (
391
- "object" !== typeof partialState &&
392
- "function" !== typeof partialState &&
393
- null != partialState
394
- )
395
- throw Error(
396
- "takes an object of state variables to update or a function which returns an object of state variables."
397
- );
398
- this.updater.enqueueSetState(this, partialState, callback, "setState");
399
- };
400
- Component.prototype.forceUpdate = function (callback) {
401
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
402
- };
403
- function ComponentDummy() {}
404
- ComponentDummy.prototype = Component.prototype;
405
- function PureComponent(props, context, updater) {
406
- this.props = props;
407
- this.context = context;
408
- this.refs = emptyObject;
409
- this.updater = updater || ReactNoopUpdateQueue;
410
- }
411
- var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
412
- pureComponentPrototype.constructor = PureComponent;
413
- assign(pureComponentPrototype, Component.prototype);
414
- pureComponentPrototype.isPureReactComponent = true;
415
- var isArrayImpl = Array.isArray;
416
- function noop() {}
417
- var ReactSharedInternals = { H: null, A: null, T: null, S: null },
418
- hasOwnProperty = Object.prototype.hasOwnProperty;
419
- function ReactElement(type, key, props) {
420
- var refProp = props.ref;
421
- return {
422
- $$typeof: REACT_ELEMENT_TYPE,
423
- type: type,
424
- key: key,
425
- ref: void 0 !== refProp ? refProp : null,
426
- props: props
427
- };
428
- }
429
- function cloneAndReplaceKey(oldElement, newKey) {
430
- return ReactElement(oldElement.type, newKey, oldElement.props);
431
- }
432
- function isValidElement(object) {
433
- return (
434
- "object" === typeof object &&
435
- null !== object &&
436
- object.$$typeof === REACT_ELEMENT_TYPE
437
- );
438
- }
439
- function escape(key) {
440
- var escaperLookup = { "=": "=0", ":": "=2" };
441
- return (
442
- "$" +
443
- key.replace(/[=:]/g, function (match) {
444
- return escaperLookup[match];
445
- })
446
- );
447
- }
448
- var userProvidedKeyEscapeRegex = /\/+/g;
449
- function getElementKey(element, index) {
450
- return "object" === typeof element && null !== element && null != element.key
451
- ? escape("" + element.key)
452
- : index.toString(36);
453
- }
454
- function resolveThenable(thenable) {
455
- switch (thenable.status) {
456
- case "fulfilled":
457
- return thenable.value;
458
- case "rejected":
459
- throw thenable.reason;
460
- default:
461
- switch (
462
- ("string" === typeof thenable.status
463
- ? thenable.then(noop, noop)
464
- : ((thenable.status = "pending"),
465
- thenable.then(
466
- function (fulfilledValue) {
467
- "pending" === thenable.status &&
468
- ((thenable.status = "fulfilled"),
469
- (thenable.value = fulfilledValue));
470
- },
471
- function (error) {
472
- "pending" === thenable.status &&
473
- ((thenable.status = "rejected"), (thenable.reason = error));
474
- }
475
- )),
476
- thenable.status)
477
- ) {
478
- case "fulfilled":
479
- return thenable.value;
480
- case "rejected":
481
- throw thenable.reason;
482
- }
483
- }
484
- throw thenable;
485
- }
486
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
487
- var type = typeof children;
488
- if ("undefined" === type || "boolean" === type) children = null;
489
- var invokeCallback = false;
490
- if (null === children) invokeCallback = true;
491
- else
492
- switch (type) {
493
- case "bigint":
494
- case "string":
495
- case "number":
496
- invokeCallback = true;
497
- break;
498
- case "object":
499
- switch (children.$$typeof) {
500
- case REACT_ELEMENT_TYPE:
501
- case REACT_PORTAL_TYPE:
502
- invokeCallback = true;
503
- break;
504
- case REACT_LAZY_TYPE:
505
- return (
506
- (invokeCallback = children._init),
507
- mapIntoArray(
508
- invokeCallback(children._payload),
509
- array,
510
- escapedPrefix,
511
- nameSoFar,
512
- callback
513
- )
514
- );
515
- }
516
- }
517
- if (invokeCallback)
518
- return (
519
- (callback = callback(children)),
520
- (invokeCallback =
521
- "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar),
522
- isArrayImpl(callback)
523
- ? ((escapedPrefix = ""),
524
- null != invokeCallback &&
525
- (escapedPrefix =
526
- invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
527
- mapIntoArray(callback, array, escapedPrefix, "", function (c) {
528
- return c;
529
- }))
530
- : null != callback &&
531
- (isValidElement(callback) &&
532
- (callback = cloneAndReplaceKey(
533
- callback,
534
- escapedPrefix +
535
- (null == callback.key ||
536
- (children && children.key === callback.key)
537
- ? ""
538
- : ("" + callback.key).replace(
539
- userProvidedKeyEscapeRegex,
540
- "$&/"
541
- ) + "/") +
542
- invokeCallback
543
- )),
544
- array.push(callback)),
545
- 1
546
- );
547
- invokeCallback = 0;
548
- var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
549
- if (isArrayImpl(children))
550
- for (var i = 0; i < children.length; i++)
551
- (nameSoFar = children[i]),
552
- (type = nextNamePrefix + getElementKey(nameSoFar, i)),
553
- (invokeCallback += mapIntoArray(
554
- nameSoFar,
555
- array,
556
- escapedPrefix,
557
- type,
558
- callback
559
- ));
560
- else if (((i = getIteratorFn(children)), "function" === typeof i))
561
- for (
562
- children = i.call(children), i = 0;
563
- !(nameSoFar = children.next()).done;
564
-
565
- )
566
- (nameSoFar = nameSoFar.value),
567
- (type = nextNamePrefix + getElementKey(nameSoFar, i++)),
568
- (invokeCallback += mapIntoArray(
569
- nameSoFar,
570
- array,
571
- escapedPrefix,
572
- type,
573
- callback
574
- ));
575
- else if ("object" === type) {
576
- if ("function" === typeof children.then)
577
- return mapIntoArray(
578
- resolveThenable(children),
579
- array,
580
- escapedPrefix,
581
- nameSoFar,
582
- callback
583
- );
584
- array = String(children);
585
- throw Error(
586
- "Objects are not valid as a React child (found: " +
587
- ("[object Object]" === array
588
- ? "object with keys {" + Object.keys(children).join(", ") + "}"
589
- : array) +
590
- "). If you meant to render a collection of children, use an array instead."
591
- );
592
- }
593
- return invokeCallback;
594
- }
595
- function mapChildren(children, func, context) {
596
- if (null == children) return children;
597
- var result = [],
598
- count = 0;
599
- mapIntoArray(children, result, "", "", function (child) {
600
- return func.call(context, child, count++);
601
- });
602
- return result;
603
- }
604
- function lazyInitializer(payload) {
605
- if (-1 === payload._status) {
606
- var ctor = payload._result;
607
- ctor = ctor();
608
- ctor.then(
609
- function (moduleObject) {
610
- if (0 === payload._status || -1 === payload._status)
611
- (payload._status = 1), (payload._result = moduleObject);
612
- },
613
- function (error) {
614
- if (0 === payload._status || -1 === payload._status)
615
- (payload._status = 2), (payload._result = error);
616
- }
617
- );
618
- -1 === payload._status && ((payload._status = 0), (payload._result = ctor));
619
- }
620
- if (1 === payload._status) return payload._result.default;
621
- throw payload._result;
622
- }
623
- var reportGlobalError =
624
- "function" === typeof reportError
625
- ? reportError
626
- : function (error) {
627
- if (
628
- "object" === typeof window &&
629
- "function" === typeof window.ErrorEvent
630
- ) {
631
- var event = new window.ErrorEvent("error", {
632
- bubbles: true,
633
- cancelable: true,
634
- message:
635
- "object" === typeof error &&
636
- null !== error &&
637
- "string" === typeof error.message
638
- ? String(error.message)
639
- : String(error),
640
- error: error
641
- });
642
- if (!window.dispatchEvent(event)) return;
643
- } else if (
644
- "object" === typeof process &&
645
- "function" === typeof process.emit
646
- ) {
647
- process.emit("uncaughtException", error);
648
- return;
649
- }
650
- console.error(error);
651
- },
652
- Children = {
653
- map: mapChildren,
654
- forEach: function (children, forEachFunc, forEachContext) {
655
- mapChildren(
656
- children,
657
- function () {
658
- forEachFunc.apply(this, arguments);
659
- },
660
- forEachContext
661
- );
662
- },
663
- count: function (children) {
664
- var n = 0;
665
- mapChildren(children, function () {
666
- n++;
667
- });
668
- return n;
669
- },
670
- toArray: function (children) {
671
- return (
672
- mapChildren(children, function (child) {
673
- return child;
674
- }) || []
675
- );
676
- },
677
- only: function (children) {
678
- if (!isValidElement(children))
679
- throw Error(
680
- "React.Children.only expected to receive a single React element child."
681
- );
682
- return children;
683
- }
684
- };
685
- react_production.Activity = REACT_ACTIVITY_TYPE;
686
- react_production.Children = Children;
687
- react_production.Component = Component;
688
- react_production.Fragment = REACT_FRAGMENT_TYPE;
689
- react_production.Profiler = REACT_PROFILER_TYPE;
690
- react_production.PureComponent = PureComponent;
691
- react_production.StrictMode = REACT_STRICT_MODE_TYPE;
692
- react_production.Suspense = REACT_SUSPENSE_TYPE;
693
- react_production.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
694
- ReactSharedInternals;
695
- react_production.__COMPILER_RUNTIME = {
696
- __proto__: null,
697
- c: function (size) {
698
- return ReactSharedInternals.H.useMemoCache(size);
699
- }
700
- };
701
- react_production.cache = function (fn) {
702
- return function () {
703
- return fn.apply(null, arguments);
704
- };
705
- };
706
- react_production.cacheSignal = function () {
707
- return null;
708
- };
709
- react_production.cloneElement = function (element, config, children) {
710
- if (null === element || void 0 === element)
711
- throw Error(
712
- "The argument must be a React element, but you passed " + element + "."
713
- );
714
- var props = assign({}, element.props),
715
- key = element.key;
716
- if (null != config)
717
- for (propName in (void 0 !== config.key && (key = "" + config.key), config))
718
- !hasOwnProperty.call(config, propName) ||
719
- "key" === propName ||
720
- "__self" === propName ||
721
- "__source" === propName ||
722
- ("ref" === propName && void 0 === config.ref) ||
723
- (props[propName] = config[propName]);
724
- var propName = arguments.length - 2;
725
- if (1 === propName) props.children = children;
726
- else if (1 < propName) {
727
- for (var childArray = Array(propName), i = 0; i < propName; i++)
728
- childArray[i] = arguments[i + 2];
729
- props.children = childArray;
730
- }
731
- return ReactElement(element.type, key, props);
732
- };
733
- react_production.createContext = function (defaultValue) {
734
- defaultValue = {
735
- $$typeof: REACT_CONTEXT_TYPE,
736
- _currentValue: defaultValue,
737
- _currentValue2: defaultValue,
738
- _threadCount: 0,
739
- Provider: null,
740
- Consumer: null
741
- };
742
- defaultValue.Provider = defaultValue;
743
- defaultValue.Consumer = {
744
- $$typeof: REACT_CONSUMER_TYPE,
745
- _context: defaultValue
746
- };
747
- return defaultValue;
748
- };
749
- react_production.createElement = function (type, config, children) {
750
- var propName,
751
- props = {},
752
- key = null;
753
- if (null != config)
754
- for (propName in (void 0 !== config.key && (key = "" + config.key), config))
755
- hasOwnProperty.call(config, propName) &&
756
- "key" !== propName &&
757
- "__self" !== propName &&
758
- "__source" !== propName &&
759
- (props[propName] = config[propName]);
760
- var childrenLength = arguments.length - 2;
761
- if (1 === childrenLength) props.children = children;
762
- else if (1 < childrenLength) {
763
- for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
764
- childArray[i] = arguments[i + 2];
765
- props.children = childArray;
766
- }
767
- if (type && type.defaultProps)
768
- for (propName in ((childrenLength = type.defaultProps), childrenLength))
769
- void 0 === props[propName] &&
770
- (props[propName] = childrenLength[propName]);
771
- return ReactElement(type, key, props);
772
- };
773
- react_production.createRef = function () {
774
- return { current: null };
775
- };
776
- react_production.forwardRef = function (render) {
777
- return { $$typeof: REACT_FORWARD_REF_TYPE, render: render };
778
- };
779
- react_production.isValidElement = isValidElement;
780
- react_production.lazy = function (ctor) {
781
- return {
782
- $$typeof: REACT_LAZY_TYPE,
783
- _payload: { _status: -1, _result: ctor },
784
- _init: lazyInitializer
785
- };
786
- };
787
- react_production.memo = function (type, compare) {
788
- return {
789
- $$typeof: REACT_MEMO_TYPE,
790
- type: type,
791
- compare: void 0 === compare ? null : compare
792
- };
793
- };
794
- react_production.startTransition = function (scope) {
795
- var prevTransition = ReactSharedInternals.T,
796
- currentTransition = {};
797
- ReactSharedInternals.T = currentTransition;
798
- try {
799
- var returnValue = scope(),
800
- onStartTransitionFinish = ReactSharedInternals.S;
801
- null !== onStartTransitionFinish &&
802
- onStartTransitionFinish(currentTransition, returnValue);
803
- "object" === typeof returnValue &&
804
- null !== returnValue &&
805
- "function" === typeof returnValue.then &&
806
- returnValue.then(noop, reportGlobalError);
807
- } catch (error) {
808
- reportGlobalError(error);
809
- } finally {
810
- null !== prevTransition &&
811
- null !== currentTransition.types &&
812
- (prevTransition.types = currentTransition.types),
813
- (ReactSharedInternals.T = prevTransition);
814
- }
815
- };
816
- react_production.unstable_useCacheRefresh = function () {
817
- return ReactSharedInternals.H.useCacheRefresh();
818
- };
819
- react_production.use = function (usable) {
820
- return ReactSharedInternals.H.use(usable);
821
- };
822
- react_production.useActionState = function (action, initialState, permalink) {
823
- return ReactSharedInternals.H.useActionState(action, initialState, permalink);
824
- };
825
- react_production.useCallback = function (callback, deps) {
826
- return ReactSharedInternals.H.useCallback(callback, deps);
827
- };
828
- react_production.useContext = function (Context) {
829
- return ReactSharedInternals.H.useContext(Context);
830
- };
831
- react_production.useDebugValue = function () {};
832
- react_production.useDeferredValue = function (value, initialValue) {
833
- return ReactSharedInternals.H.useDeferredValue(value, initialValue);
834
- };
835
- react_production.useEffect = function (create, deps) {
836
- return ReactSharedInternals.H.useEffect(create, deps);
837
- };
838
- react_production.useEffectEvent = function (callback) {
839
- return ReactSharedInternals.H.useEffectEvent(callback);
840
- };
841
- react_production.useId = function () {
842
- return ReactSharedInternals.H.useId();
843
- };
844
- react_production.useImperativeHandle = function (ref, create, deps) {
845
- return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
846
- };
847
- react_production.useInsertionEffect = function (create, deps) {
848
- return ReactSharedInternals.H.useInsertionEffect(create, deps);
849
- };
850
- react_production.useLayoutEffect = function (create, deps) {
851
- return ReactSharedInternals.H.useLayoutEffect(create, deps);
852
- };
853
- react_production.useMemo = function (create, deps) {
854
- return ReactSharedInternals.H.useMemo(create, deps);
855
- };
856
- react_production.useOptimistic = function (passthrough, reducer) {
857
- return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
858
- };
859
- react_production.useReducer = function (reducer, initialArg, init) {
860
- return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
861
- };
862
- react_production.useRef = function (initialValue) {
863
- return ReactSharedInternals.H.useRef(initialValue);
864
- };
865
- react_production.useState = function (initialState) {
866
- return ReactSharedInternals.H.useState(initialState);
867
- };
868
- react_production.useSyncExternalStore = function (
869
- subscribe,
870
- getSnapshot,
871
- getServerSnapshot
872
- ) {
873
- return ReactSharedInternals.H.useSyncExternalStore(
874
- subscribe,
875
- getSnapshot,
876
- getServerSnapshot
877
- );
878
- };
879
- react_production.useTransition = function () {
880
- return ReactSharedInternals.H.useTransition();
881
- };
882
- react_production.version = "19.2.4";
883
- return react_production;
884
- }
885
-
886
- var react_development = {exports: {}};
887
-
888
- /**
889
- * @license React
890
- * react.development.js
891
- *
892
- * Copyright (c) Meta Platforms, Inc. and affiliates.
893
- *
894
- * This source code is licensed under the MIT license found in the
895
- * LICENSE file in the root directory of this source tree.
896
- */
897
- react_development.exports;
898
-
899
- var hasRequiredReact_development;
900
-
901
- function requireReact_development () {
902
- if (hasRequiredReact_development) return react_development.exports;
903
- hasRequiredReact_development = 1;
904
- (function (module, exports$1) {
905
- "production" !== process.env.NODE_ENV &&
906
- (function () {
907
- function defineDeprecationWarning(methodName, info) {
908
- Object.defineProperty(Component.prototype, methodName, {
909
- get: function () {
910
- console.warn(
911
- "%s(...) is deprecated in plain JavaScript React classes. %s",
912
- info[0],
913
- info[1]
914
- );
915
- }
916
- });
917
- }
918
- function getIteratorFn(maybeIterable) {
919
- if (null === maybeIterable || "object" !== typeof maybeIterable)
920
- return null;
921
- maybeIterable =
922
- (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
923
- maybeIterable["@@iterator"];
924
- return "function" === typeof maybeIterable ? maybeIterable : null;
925
- }
926
- function warnNoop(publicInstance, callerName) {
927
- publicInstance =
928
- ((publicInstance = publicInstance.constructor) &&
929
- (publicInstance.displayName || publicInstance.name)) ||
930
- "ReactClass";
931
- var warningKey = publicInstance + "." + callerName;
932
- didWarnStateUpdateForUnmountedComponent[warningKey] ||
933
- (console.error(
934
- "Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
935
- callerName,
936
- publicInstance
937
- ),
938
- (didWarnStateUpdateForUnmountedComponent[warningKey] = true));
939
- }
940
- function Component(props, context, updater) {
941
- this.props = props;
942
- this.context = context;
943
- this.refs = emptyObject;
944
- this.updater = updater || ReactNoopUpdateQueue;
945
- }
946
- function ComponentDummy() {}
947
- function PureComponent(props, context, updater) {
948
- this.props = props;
949
- this.context = context;
950
- this.refs = emptyObject;
951
- this.updater = updater || ReactNoopUpdateQueue;
952
- }
953
- function noop() {}
954
- function testStringCoercion(value) {
955
- return "" + value;
956
- }
957
- function checkKeyStringCoercion(value) {
958
- try {
959
- testStringCoercion(value);
960
- var JSCompiler_inline_result = !1;
961
- } catch (e) {
962
- JSCompiler_inline_result = true;
963
- }
964
- if (JSCompiler_inline_result) {
965
- JSCompiler_inline_result = console;
966
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
967
- var JSCompiler_inline_result$jscomp$0 =
968
- ("function" === typeof Symbol &&
969
- Symbol.toStringTag &&
970
- value[Symbol.toStringTag]) ||
971
- value.constructor.name ||
972
- "Object";
973
- JSCompiler_temp_const.call(
974
- JSCompiler_inline_result,
975
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
976
- JSCompiler_inline_result$jscomp$0
977
- );
978
- return testStringCoercion(value);
979
- }
980
- }
981
- function getComponentNameFromType(type) {
982
- if (null == type) return null;
983
- if ("function" === typeof type)
984
- return type.$$typeof === REACT_CLIENT_REFERENCE
985
- ? null
986
- : type.displayName || type.name || null;
987
- if ("string" === typeof type) return type;
988
- switch (type) {
989
- case REACT_FRAGMENT_TYPE:
990
- return "Fragment";
991
- case REACT_PROFILER_TYPE:
992
- return "Profiler";
993
- case REACT_STRICT_MODE_TYPE:
994
- return "StrictMode";
995
- case REACT_SUSPENSE_TYPE:
996
- return "Suspense";
997
- case REACT_SUSPENSE_LIST_TYPE:
998
- return "SuspenseList";
999
- case REACT_ACTIVITY_TYPE:
1000
- return "Activity";
1001
- }
1002
- if ("object" === typeof type)
1003
- switch (
1004
- ("number" === typeof type.tag &&
1005
- console.error(
1006
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
1007
- ),
1008
- type.$$typeof)
1009
- ) {
1010
- case REACT_PORTAL_TYPE:
1011
- return "Portal";
1012
- case REACT_CONTEXT_TYPE:
1013
- return type.displayName || "Context";
1014
- case REACT_CONSUMER_TYPE:
1015
- return (type._context.displayName || "Context") + ".Consumer";
1016
- case REACT_FORWARD_REF_TYPE:
1017
- var innerType = type.render;
1018
- type = type.displayName;
1019
- type ||
1020
- ((type = innerType.displayName || innerType.name || ""),
1021
- (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
1022
- return type;
1023
- case REACT_MEMO_TYPE:
1024
- return (
1025
- (innerType = type.displayName || null),
1026
- null !== innerType
1027
- ? innerType
1028
- : getComponentNameFromType(type.type) || "Memo"
1029
- );
1030
- case REACT_LAZY_TYPE:
1031
- innerType = type._payload;
1032
- type = type._init;
1033
- try {
1034
- return getComponentNameFromType(type(innerType));
1035
- } catch (x) {}
1036
- }
1037
- return null;
1038
- }
1039
- function getTaskName(type) {
1040
- if (type === REACT_FRAGMENT_TYPE) return "<>";
1041
- if (
1042
- "object" === typeof type &&
1043
- null !== type &&
1044
- type.$$typeof === REACT_LAZY_TYPE
1045
- )
1046
- return "<...>";
1047
- try {
1048
- var name = getComponentNameFromType(type);
1049
- return name ? "<" + name + ">" : "<...>";
1050
- } catch (x) {
1051
- return "<...>";
1052
- }
1053
- }
1054
- function getOwner() {
1055
- var dispatcher = ReactSharedInternals.A;
1056
- return null === dispatcher ? null : dispatcher.getOwner();
1057
- }
1058
- function UnknownOwner() {
1059
- return Error("react-stack-top-frame");
1060
- }
1061
- function hasValidKey(config) {
1062
- if (hasOwnProperty.call(config, "key")) {
1063
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
1064
- if (getter && getter.isReactWarning) return false;
1065
- }
1066
- return void 0 !== config.key;
1067
- }
1068
- function defineKeyPropWarningGetter(props, displayName) {
1069
- function warnAboutAccessingKey() {
1070
- specialPropKeyWarningShown ||
1071
- ((specialPropKeyWarningShown = true),
1072
- console.error(
1073
- "%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://react.dev/link/special-props)",
1074
- displayName
1075
- ));
1076
- }
1077
- warnAboutAccessingKey.isReactWarning = true;
1078
- Object.defineProperty(props, "key", {
1079
- get: warnAboutAccessingKey,
1080
- configurable: true
1081
- });
1082
- }
1083
- function elementRefGetterWithDeprecationWarning() {
1084
- var componentName = getComponentNameFromType(this.type);
1085
- didWarnAboutElementRef[componentName] ||
1086
- ((didWarnAboutElementRef[componentName] = true),
1087
- console.error(
1088
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
1089
- ));
1090
- componentName = this.props.ref;
1091
- return void 0 !== componentName ? componentName : null;
1092
- }
1093
- function ReactElement(type, key, props, owner, debugStack, debugTask) {
1094
- var refProp = props.ref;
1095
- type = {
1096
- $$typeof: REACT_ELEMENT_TYPE,
1097
- type: type,
1098
- key: key,
1099
- props: props,
1100
- _owner: owner
1101
- };
1102
- null !== (void 0 !== refProp ? refProp : null)
1103
- ? Object.defineProperty(type, "ref", {
1104
- enumerable: false,
1105
- get: elementRefGetterWithDeprecationWarning
1106
- })
1107
- : Object.defineProperty(type, "ref", { enumerable: false, value: null });
1108
- type._store = {};
1109
- Object.defineProperty(type._store, "validated", {
1110
- configurable: false,
1111
- enumerable: false,
1112
- writable: true,
1113
- value: 0
1114
- });
1115
- Object.defineProperty(type, "_debugInfo", {
1116
- configurable: false,
1117
- enumerable: false,
1118
- writable: true,
1119
- value: null
1120
- });
1121
- Object.defineProperty(type, "_debugStack", {
1122
- configurable: false,
1123
- enumerable: false,
1124
- writable: true,
1125
- value: debugStack
1126
- });
1127
- Object.defineProperty(type, "_debugTask", {
1128
- configurable: false,
1129
- enumerable: false,
1130
- writable: true,
1131
- value: debugTask
1132
- });
1133
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
1134
- return type;
1135
- }
1136
- function cloneAndReplaceKey(oldElement, newKey) {
1137
- newKey = ReactElement(
1138
- oldElement.type,
1139
- newKey,
1140
- oldElement.props,
1141
- oldElement._owner,
1142
- oldElement._debugStack,
1143
- oldElement._debugTask
1144
- );
1145
- oldElement._store &&
1146
- (newKey._store.validated = oldElement._store.validated);
1147
- return newKey;
1148
- }
1149
- function validateChildKeys(node) {
1150
- isValidElement(node)
1151
- ? node._store && (node._store.validated = 1)
1152
- : "object" === typeof node &&
1153
- null !== node &&
1154
- node.$$typeof === REACT_LAZY_TYPE &&
1155
- ("fulfilled" === node._payload.status
1156
- ? isValidElement(node._payload.value) &&
1157
- node._payload.value._store &&
1158
- (node._payload.value._store.validated = 1)
1159
- : node._store && (node._store.validated = 1));
1160
- }
1161
- function isValidElement(object) {
1162
- return (
1163
- "object" === typeof object &&
1164
- null !== object &&
1165
- object.$$typeof === REACT_ELEMENT_TYPE
1166
- );
1167
- }
1168
- function escape(key) {
1169
- var escaperLookup = { "=": "=0", ":": "=2" };
1170
- return (
1171
- "$" +
1172
- key.replace(/[=:]/g, function (match) {
1173
- return escaperLookup[match];
1174
- })
1175
- );
1176
- }
1177
- function getElementKey(element, index) {
1178
- return "object" === typeof element &&
1179
- null !== element &&
1180
- null != element.key
1181
- ? (checkKeyStringCoercion(element.key), escape("" + element.key))
1182
- : index.toString(36);
1183
- }
1184
- function resolveThenable(thenable) {
1185
- switch (thenable.status) {
1186
- case "fulfilled":
1187
- return thenable.value;
1188
- case "rejected":
1189
- throw thenable.reason;
1190
- default:
1191
- switch (
1192
- ("string" === typeof thenable.status
1193
- ? thenable.then(noop, noop)
1194
- : ((thenable.status = "pending"),
1195
- thenable.then(
1196
- function (fulfilledValue) {
1197
- "pending" === thenable.status &&
1198
- ((thenable.status = "fulfilled"),
1199
- (thenable.value = fulfilledValue));
1200
- },
1201
- function (error) {
1202
- "pending" === thenable.status &&
1203
- ((thenable.status = "rejected"),
1204
- (thenable.reason = error));
1205
- }
1206
- )),
1207
- thenable.status)
1208
- ) {
1209
- case "fulfilled":
1210
- return thenable.value;
1211
- case "rejected":
1212
- throw thenable.reason;
1213
- }
1214
- }
1215
- throw thenable;
1216
- }
1217
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1218
- var type = typeof children;
1219
- if ("undefined" === type || "boolean" === type) children = null;
1220
- var invokeCallback = false;
1221
- if (null === children) invokeCallback = true;
1222
- else
1223
- switch (type) {
1224
- case "bigint":
1225
- case "string":
1226
- case "number":
1227
- invokeCallback = true;
1228
- break;
1229
- case "object":
1230
- switch (children.$$typeof) {
1231
- case REACT_ELEMENT_TYPE:
1232
- case REACT_PORTAL_TYPE:
1233
- invokeCallback = true;
1234
- break;
1235
- case REACT_LAZY_TYPE:
1236
- return (
1237
- (invokeCallback = children._init),
1238
- mapIntoArray(
1239
- invokeCallback(children._payload),
1240
- array,
1241
- escapedPrefix,
1242
- nameSoFar,
1243
- callback
1244
- )
1245
- );
1246
- }
1247
- }
1248
- if (invokeCallback) {
1249
- invokeCallback = children;
1250
- callback = callback(invokeCallback);
1251
- var childKey =
1252
- "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
1253
- isArrayImpl(callback)
1254
- ? ((escapedPrefix = ""),
1255
- null != childKey &&
1256
- (escapedPrefix =
1257
- childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
1258
- mapIntoArray(callback, array, escapedPrefix, "", function (c) {
1259
- return c;
1260
- }))
1261
- : null != callback &&
1262
- (isValidElement(callback) &&
1263
- (null != callback.key &&
1264
- ((invokeCallback && invokeCallback.key === callback.key) ||
1265
- checkKeyStringCoercion(callback.key)),
1266
- (escapedPrefix = cloneAndReplaceKey(
1267
- callback,
1268
- escapedPrefix +
1269
- (null == callback.key ||
1270
- (invokeCallback && invokeCallback.key === callback.key)
1271
- ? ""
1272
- : ("" + callback.key).replace(
1273
- userProvidedKeyEscapeRegex,
1274
- "$&/"
1275
- ) + "/") +
1276
- childKey
1277
- )),
1278
- "" !== nameSoFar &&
1279
- null != invokeCallback &&
1280
- isValidElement(invokeCallback) &&
1281
- null == invokeCallback.key &&
1282
- invokeCallback._store &&
1283
- !invokeCallback._store.validated &&
1284
- (escapedPrefix._store.validated = 2),
1285
- (callback = escapedPrefix)),
1286
- array.push(callback));
1287
- return 1;
1288
- }
1289
- invokeCallback = 0;
1290
- childKey = "" === nameSoFar ? "." : nameSoFar + ":";
1291
- if (isArrayImpl(children))
1292
- for (var i = 0; i < children.length; i++)
1293
- (nameSoFar = children[i]),
1294
- (type = childKey + getElementKey(nameSoFar, i)),
1295
- (invokeCallback += mapIntoArray(
1296
- nameSoFar,
1297
- array,
1298
- escapedPrefix,
1299
- type,
1300
- callback
1301
- ));
1302
- else if (((i = getIteratorFn(children)), "function" === typeof i))
1303
- for (
1304
- i === children.entries &&
1305
- (didWarnAboutMaps ||
1306
- console.warn(
1307
- "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
1308
- ),
1309
- (didWarnAboutMaps = true)),
1310
- children = i.call(children),
1311
- i = 0;
1312
- !(nameSoFar = children.next()).done;
1313
-
1314
- )
1315
- (nameSoFar = nameSoFar.value),
1316
- (type = childKey + getElementKey(nameSoFar, i++)),
1317
- (invokeCallback += mapIntoArray(
1318
- nameSoFar,
1319
- array,
1320
- escapedPrefix,
1321
- type,
1322
- callback
1323
- ));
1324
- else if ("object" === type) {
1325
- if ("function" === typeof children.then)
1326
- return mapIntoArray(
1327
- resolveThenable(children),
1328
- array,
1329
- escapedPrefix,
1330
- nameSoFar,
1331
- callback
1332
- );
1333
- array = String(children);
1334
- throw Error(
1335
- "Objects are not valid as a React child (found: " +
1336
- ("[object Object]" === array
1337
- ? "object with keys {" + Object.keys(children).join(", ") + "}"
1338
- : array) +
1339
- "). If you meant to render a collection of children, use an array instead."
1340
- );
1341
- }
1342
- return invokeCallback;
1343
- }
1344
- function mapChildren(children, func, context) {
1345
- if (null == children) return children;
1346
- var result = [],
1347
- count = 0;
1348
- mapIntoArray(children, result, "", "", function (child) {
1349
- return func.call(context, child, count++);
1350
- });
1351
- return result;
1352
- }
1353
- function lazyInitializer(payload) {
1354
- if (-1 === payload._status) {
1355
- var ioInfo = payload._ioInfo;
1356
- null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
1357
- ioInfo = payload._result;
1358
- var thenable = ioInfo();
1359
- thenable.then(
1360
- function (moduleObject) {
1361
- if (0 === payload._status || -1 === payload._status) {
1362
- payload._status = 1;
1363
- payload._result = moduleObject;
1364
- var _ioInfo = payload._ioInfo;
1365
- null != _ioInfo && (_ioInfo.end = performance.now());
1366
- void 0 === thenable.status &&
1367
- ((thenable.status = "fulfilled"),
1368
- (thenable.value = moduleObject));
1369
- }
1370
- },
1371
- function (error) {
1372
- if (0 === payload._status || -1 === payload._status) {
1373
- payload._status = 2;
1374
- payload._result = error;
1375
- var _ioInfo2 = payload._ioInfo;
1376
- null != _ioInfo2 && (_ioInfo2.end = performance.now());
1377
- void 0 === thenable.status &&
1378
- ((thenable.status = "rejected"), (thenable.reason = error));
1379
- }
1380
- }
1381
- );
1382
- ioInfo = payload._ioInfo;
1383
- if (null != ioInfo) {
1384
- ioInfo.value = thenable;
1385
- var displayName = thenable.displayName;
1386
- "string" === typeof displayName && (ioInfo.name = displayName);
1387
- }
1388
- -1 === payload._status &&
1389
- ((payload._status = 0), (payload._result = thenable));
1390
- }
1391
- if (1 === payload._status)
1392
- return (
1393
- (ioInfo = payload._result),
1394
- void 0 === ioInfo &&
1395
- console.error(
1396
- "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
1397
- ioInfo
1398
- ),
1399
- "default" in ioInfo ||
1400
- console.error(
1401
- "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
1402
- ioInfo
1403
- ),
1404
- ioInfo.default
1405
- );
1406
- throw payload._result;
1407
- }
1408
- function resolveDispatcher() {
1409
- var dispatcher = ReactSharedInternals.H;
1410
- null === dispatcher &&
1411
- console.error(
1412
- "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
1413
- );
1414
- return dispatcher;
1415
- }
1416
- function releaseAsyncTransition() {
1417
- ReactSharedInternals.asyncTransitions--;
1418
- }
1419
- function enqueueTask(task) {
1420
- if (null === enqueueTaskImpl)
1421
- try {
1422
- var requireString = ("require" + Math.random()).slice(0, 7);
1423
- enqueueTaskImpl = (module && module[requireString]).call(
1424
- module,
1425
- "timers"
1426
- ).setImmediate;
1427
- } catch (_err) {
1428
- enqueueTaskImpl = function (callback) {
1429
- false === didWarnAboutMessageChannel &&
1430
- ((didWarnAboutMessageChannel = true),
1431
- "undefined" === typeof MessageChannel &&
1432
- console.error(
1433
- "This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
1434
- ));
1435
- var channel = new MessageChannel();
1436
- channel.port1.onmessage = callback;
1437
- channel.port2.postMessage(void 0);
1438
- };
1439
- }
1440
- return enqueueTaskImpl(task);
1441
- }
1442
- function aggregateErrors(errors) {
1443
- return 1 < errors.length && "function" === typeof AggregateError
1444
- ? new AggregateError(errors)
1445
- : errors[0];
1446
- }
1447
- function popActScope(prevActQueue, prevActScopeDepth) {
1448
- prevActScopeDepth !== actScopeDepth - 1 &&
1449
- console.error(
1450
- "You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
1451
- );
1452
- actScopeDepth = prevActScopeDepth;
1453
- }
1454
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
1455
- var queue = ReactSharedInternals.actQueue;
1456
- if (null !== queue)
1457
- if (0 !== queue.length)
1458
- try {
1459
- flushActQueue(queue);
1460
- enqueueTask(function () {
1461
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
1462
- });
1463
- return;
1464
- } catch (error) {
1465
- ReactSharedInternals.thrownErrors.push(error);
1466
- }
1467
- else ReactSharedInternals.actQueue = null;
1468
- 0 < ReactSharedInternals.thrownErrors.length
1469
- ? ((queue = aggregateErrors(ReactSharedInternals.thrownErrors)),
1470
- (ReactSharedInternals.thrownErrors.length = 0),
1471
- reject(queue))
1472
- : resolve(returnValue);
1473
- }
1474
- function flushActQueue(queue) {
1475
- if (!isFlushing) {
1476
- isFlushing = true;
1477
- var i = 0;
1478
- try {
1479
- for (; i < queue.length; i++) {
1480
- var callback = queue[i];
1481
- do {
1482
- ReactSharedInternals.didUsePromise = !1;
1483
- var continuation = callback(!1);
1484
- if (null !== continuation) {
1485
- if (ReactSharedInternals.didUsePromise) {
1486
- queue[i] = callback;
1487
- queue.splice(0, i);
1488
- return;
1489
- }
1490
- callback = continuation;
1491
- } else break;
1492
- } while (1);
1493
- }
1494
- queue.length = 0;
1495
- } catch (error) {
1496
- queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
1497
- } finally {
1498
- isFlushing = false;
1499
- }
1500
- }
1501
- }
1502
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1503
- "function" ===
1504
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
1505
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1506
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
1507
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
1508
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
1509
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
1510
- REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
1511
- REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
1512
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
1513
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
1514
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
1515
- REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
1516
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
1517
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
1518
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
1519
- MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
1520
- didWarnStateUpdateForUnmountedComponent = {},
1521
- ReactNoopUpdateQueue = {
1522
- isMounted: function () {
1523
- return false;
1524
- },
1525
- enqueueForceUpdate: function (publicInstance) {
1526
- warnNoop(publicInstance, "forceUpdate");
1527
- },
1528
- enqueueReplaceState: function (publicInstance) {
1529
- warnNoop(publicInstance, "replaceState");
1530
- },
1531
- enqueueSetState: function (publicInstance) {
1532
- warnNoop(publicInstance, "setState");
1533
- }
1534
- },
1535
- assign = Object.assign,
1536
- emptyObject = {};
1537
- Object.freeze(emptyObject);
1538
- Component.prototype.isReactComponent = {};
1539
- Component.prototype.setState = function (partialState, callback) {
1540
- if (
1541
- "object" !== typeof partialState &&
1542
- "function" !== typeof partialState &&
1543
- null != partialState
1544
- )
1545
- throw Error(
1546
- "takes an object of state variables to update or a function which returns an object of state variables."
1547
- );
1548
- this.updater.enqueueSetState(this, partialState, callback, "setState");
1549
- };
1550
- Component.prototype.forceUpdate = function (callback) {
1551
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
1552
- };
1553
- var deprecatedAPIs = {
1554
- isMounted: [
1555
- "isMounted",
1556
- "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
1557
- ],
1558
- replaceState: [
1559
- "replaceState",
1560
- "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
1561
- ]
1562
- };
1563
- for (fnName in deprecatedAPIs)
1564
- deprecatedAPIs.hasOwnProperty(fnName) &&
1565
- defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
1566
- ComponentDummy.prototype = Component.prototype;
1567
- deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
1568
- deprecatedAPIs.constructor = PureComponent;
1569
- assign(deprecatedAPIs, Component.prototype);
1570
- deprecatedAPIs.isPureReactComponent = true;
1571
- var isArrayImpl = Array.isArray,
1572
- REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
1573
- ReactSharedInternals = {
1574
- H: null,
1575
- A: null,
1576
- T: null,
1577
- S: null,
1578
- actQueue: null,
1579
- asyncTransitions: 0,
1580
- isBatchingLegacy: false,
1581
- didScheduleLegacyUpdate: false,
1582
- didUsePromise: false,
1583
- thrownErrors: [],
1584
- getCurrentStack: null,
1585
- recentlyCreatedOwnerStacks: 0
1586
- },
1587
- hasOwnProperty = Object.prototype.hasOwnProperty,
1588
- createTask = console.createTask
1589
- ? console.createTask
1590
- : function () {
1591
- return null;
1592
- };
1593
- deprecatedAPIs = {
1594
- react_stack_bottom_frame: function (callStackForError) {
1595
- return callStackForError();
1596
- }
1597
- };
1598
- var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
1599
- var didWarnAboutElementRef = {};
1600
- var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
1601
- deprecatedAPIs,
1602
- UnknownOwner
1603
- )();
1604
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1605
- var didWarnAboutMaps = false,
1606
- userProvidedKeyEscapeRegex = /\/+/g,
1607
- reportGlobalError =
1608
- "function" === typeof reportError
1609
- ? reportError
1610
- : function (error) {
1611
- if (
1612
- "object" === typeof window &&
1613
- "function" === typeof window.ErrorEvent
1614
- ) {
1615
- var event = new window.ErrorEvent("error", {
1616
- bubbles: true,
1617
- cancelable: true,
1618
- message:
1619
- "object" === typeof error &&
1620
- null !== error &&
1621
- "string" === typeof error.message
1622
- ? String(error.message)
1623
- : String(error),
1624
- error: error
1625
- });
1626
- if (!window.dispatchEvent(event)) return;
1627
- } else if (
1628
- "object" === typeof process &&
1629
- "function" === typeof process.emit
1630
- ) {
1631
- process.emit("uncaughtException", error);
1632
- return;
1633
- }
1634
- console.error(error);
1635
- },
1636
- didWarnAboutMessageChannel = false,
1637
- enqueueTaskImpl = null,
1638
- actScopeDepth = 0,
1639
- didWarnNoAwaitAct = false,
1640
- isFlushing = false,
1641
- queueSeveralMicrotasks =
1642
- "function" === typeof queueMicrotask
1643
- ? function (callback) {
1644
- queueMicrotask(function () {
1645
- return queueMicrotask(callback);
1646
- });
1647
- }
1648
- : enqueueTask;
1649
- deprecatedAPIs = Object.freeze({
1650
- __proto__: null,
1651
- c: function (size) {
1652
- return resolveDispatcher().useMemoCache(size);
1653
- }
1654
- });
1655
- var fnName = {
1656
- map: mapChildren,
1657
- forEach: function (children, forEachFunc, forEachContext) {
1658
- mapChildren(
1659
- children,
1660
- function () {
1661
- forEachFunc.apply(this, arguments);
1662
- },
1663
- forEachContext
1664
- );
1665
- },
1666
- count: function (children) {
1667
- var n = 0;
1668
- mapChildren(children, function () {
1669
- n++;
1670
- });
1671
- return n;
1672
- },
1673
- toArray: function (children) {
1674
- return (
1675
- mapChildren(children, function (child) {
1676
- return child;
1677
- }) || []
1678
- );
1679
- },
1680
- only: function (children) {
1681
- if (!isValidElement(children))
1682
- throw Error(
1683
- "React.Children.only expected to receive a single React element child."
1684
- );
1685
- return children;
1686
- }
1687
- };
1688
- exports$1.Activity = REACT_ACTIVITY_TYPE;
1689
- exports$1.Children = fnName;
1690
- exports$1.Component = Component;
1691
- exports$1.Fragment = REACT_FRAGMENT_TYPE;
1692
- exports$1.Profiler = REACT_PROFILER_TYPE;
1693
- exports$1.PureComponent = PureComponent;
1694
- exports$1.StrictMode = REACT_STRICT_MODE_TYPE;
1695
- exports$1.Suspense = REACT_SUSPENSE_TYPE;
1696
- exports$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
1697
- ReactSharedInternals;
1698
- exports$1.__COMPILER_RUNTIME = deprecatedAPIs;
1699
- exports$1.act = function (callback) {
1700
- var prevActQueue = ReactSharedInternals.actQueue,
1701
- prevActScopeDepth = actScopeDepth;
1702
- actScopeDepth++;
1703
- var queue = (ReactSharedInternals.actQueue =
1704
- null !== prevActQueue ? prevActQueue : []),
1705
- didAwaitActCall = false;
1706
- try {
1707
- var result = callback();
1708
- } catch (error) {
1709
- ReactSharedInternals.thrownErrors.push(error);
1710
- }
1711
- if (0 < ReactSharedInternals.thrownErrors.length)
1712
- throw (
1713
- (popActScope(prevActQueue, prevActScopeDepth),
1714
- (callback = aggregateErrors(ReactSharedInternals.thrownErrors)),
1715
- (ReactSharedInternals.thrownErrors.length = 0),
1716
- callback)
1717
- );
1718
- if (
1719
- null !== result &&
1720
- "object" === typeof result &&
1721
- "function" === typeof result.then
1722
- ) {
1723
- var thenable = result;
1724
- queueSeveralMicrotasks(function () {
1725
- didAwaitActCall ||
1726
- didWarnNoAwaitAct ||
1727
- ((didWarnNoAwaitAct = true),
1728
- console.error(
1729
- "You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
1730
- ));
1731
- });
1732
- return {
1733
- then: function (resolve, reject) {
1734
- didAwaitActCall = true;
1735
- thenable.then(
1736
- function (returnValue) {
1737
- popActScope(prevActQueue, prevActScopeDepth);
1738
- if (0 === prevActScopeDepth) {
1739
- try {
1740
- flushActQueue(queue),
1741
- enqueueTask(function () {
1742
- return recursivelyFlushAsyncActWork(
1743
- returnValue,
1744
- resolve,
1745
- reject
1746
- );
1747
- });
1748
- } catch (error$0) {
1749
- ReactSharedInternals.thrownErrors.push(error$0);
1750
- }
1751
- if (0 < ReactSharedInternals.thrownErrors.length) {
1752
- var _thrownError = aggregateErrors(
1753
- ReactSharedInternals.thrownErrors
1754
- );
1755
- ReactSharedInternals.thrownErrors.length = 0;
1756
- reject(_thrownError);
1757
- }
1758
- } else resolve(returnValue);
1759
- },
1760
- function (error) {
1761
- popActScope(prevActQueue, prevActScopeDepth);
1762
- 0 < ReactSharedInternals.thrownErrors.length
1763
- ? ((error = aggregateErrors(
1764
- ReactSharedInternals.thrownErrors
1765
- )),
1766
- (ReactSharedInternals.thrownErrors.length = 0),
1767
- reject(error))
1768
- : reject(error);
1769
- }
1770
- );
1771
- }
1772
- };
1773
- }
1774
- var returnValue$jscomp$0 = result;
1775
- popActScope(prevActQueue, prevActScopeDepth);
1776
- 0 === prevActScopeDepth &&
1777
- (flushActQueue(queue),
1778
- 0 !== queue.length &&
1779
- queueSeveralMicrotasks(function () {
1780
- didAwaitActCall ||
1781
- didWarnNoAwaitAct ||
1782
- ((didWarnNoAwaitAct = true),
1783
- console.error(
1784
- "A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
1785
- ));
1786
- }),
1787
- (ReactSharedInternals.actQueue = null));
1788
- if (0 < ReactSharedInternals.thrownErrors.length)
1789
- throw (
1790
- ((callback = aggregateErrors(ReactSharedInternals.thrownErrors)),
1791
- (ReactSharedInternals.thrownErrors.length = 0),
1792
- callback)
1793
- );
1794
- return {
1795
- then: function (resolve, reject) {
1796
- didAwaitActCall = true;
1797
- 0 === prevActScopeDepth
1798
- ? ((ReactSharedInternals.actQueue = queue),
1799
- enqueueTask(function () {
1800
- return recursivelyFlushAsyncActWork(
1801
- returnValue$jscomp$0,
1802
- resolve,
1803
- reject
1804
- );
1805
- }))
1806
- : resolve(returnValue$jscomp$0);
1807
- }
1808
- };
1809
- };
1810
- exports$1.cache = function (fn) {
1811
- return function () {
1812
- return fn.apply(null, arguments);
1813
- };
1814
- };
1815
- exports$1.cacheSignal = function () {
1816
- return null;
1817
- };
1818
- exports$1.captureOwnerStack = function () {
1819
- var getCurrentStack = ReactSharedInternals.getCurrentStack;
1820
- return null === getCurrentStack ? null : getCurrentStack();
1821
- };
1822
- exports$1.cloneElement = function (element, config, children) {
1823
- if (null === element || void 0 === element)
1824
- throw Error(
1825
- "The argument must be a React element, but you passed " +
1826
- element +
1827
- "."
1828
- );
1829
- var props = assign({}, element.props),
1830
- key = element.key,
1831
- owner = element._owner;
1832
- if (null != config) {
1833
- var JSCompiler_inline_result;
1834
- a: {
1835
- if (
1836
- hasOwnProperty.call(config, "ref") &&
1837
- (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
1838
- config,
1839
- "ref"
1840
- ).get) &&
1841
- JSCompiler_inline_result.isReactWarning
1842
- ) {
1843
- JSCompiler_inline_result = false;
1844
- break a;
1845
- }
1846
- JSCompiler_inline_result = void 0 !== config.ref;
1847
- }
1848
- JSCompiler_inline_result && (owner = getOwner());
1849
- hasValidKey(config) &&
1850
- (checkKeyStringCoercion(config.key), (key = "" + config.key));
1851
- for (propName in config)
1852
- !hasOwnProperty.call(config, propName) ||
1853
- "key" === propName ||
1854
- "__self" === propName ||
1855
- "__source" === propName ||
1856
- ("ref" === propName && void 0 === config.ref) ||
1857
- (props[propName] = config[propName]);
1858
- }
1859
- var propName = arguments.length - 2;
1860
- if (1 === propName) props.children = children;
1861
- else if (1 < propName) {
1862
- JSCompiler_inline_result = Array(propName);
1863
- for (var i = 0; i < propName; i++)
1864
- JSCompiler_inline_result[i] = arguments[i + 2];
1865
- props.children = JSCompiler_inline_result;
1866
- }
1867
- props = ReactElement(
1868
- element.type,
1869
- key,
1870
- props,
1871
- owner,
1872
- element._debugStack,
1873
- element._debugTask
1874
- );
1875
- for (key = 2; key < arguments.length; key++)
1876
- validateChildKeys(arguments[key]);
1877
- return props;
1878
- };
1879
- exports$1.createContext = function (defaultValue) {
1880
- defaultValue = {
1881
- $$typeof: REACT_CONTEXT_TYPE,
1882
- _currentValue: defaultValue,
1883
- _currentValue2: defaultValue,
1884
- _threadCount: 0,
1885
- Provider: null,
1886
- Consumer: null
1887
- };
1888
- defaultValue.Provider = defaultValue;
1889
- defaultValue.Consumer = {
1890
- $$typeof: REACT_CONSUMER_TYPE,
1891
- _context: defaultValue
1892
- };
1893
- defaultValue._currentRenderer = null;
1894
- defaultValue._currentRenderer2 = null;
1895
- return defaultValue;
1896
- };
1897
- exports$1.createElement = function (type, config, children) {
1898
- for (var i = 2; i < arguments.length; i++)
1899
- validateChildKeys(arguments[i]);
1900
- i = {};
1901
- var key = null;
1902
- if (null != config)
1903
- for (propName in (didWarnAboutOldJSXRuntime ||
1904
- !("__self" in config) ||
1905
- "key" in config ||
1906
- ((didWarnAboutOldJSXRuntime = true),
1907
- console.warn(
1908
- "Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
1909
- )),
1910
- hasValidKey(config) &&
1911
- (checkKeyStringCoercion(config.key), (key = "" + config.key)),
1912
- config))
1913
- hasOwnProperty.call(config, propName) &&
1914
- "key" !== propName &&
1915
- "__self" !== propName &&
1916
- "__source" !== propName &&
1917
- (i[propName] = config[propName]);
1918
- var childrenLength = arguments.length - 2;
1919
- if (1 === childrenLength) i.children = children;
1920
- else if (1 < childrenLength) {
1921
- for (
1922
- var childArray = Array(childrenLength), _i = 0;
1923
- _i < childrenLength;
1924
- _i++
1925
- )
1926
- childArray[_i] = arguments[_i + 2];
1927
- Object.freeze && Object.freeze(childArray);
1928
- i.children = childArray;
1929
- }
1930
- if (type && type.defaultProps)
1931
- for (propName in ((childrenLength = type.defaultProps), childrenLength))
1932
- void 0 === i[propName] && (i[propName] = childrenLength[propName]);
1933
- key &&
1934
- defineKeyPropWarningGetter(
1935
- i,
1936
- "function" === typeof type
1937
- ? type.displayName || type.name || "Unknown"
1938
- : type
1939
- );
1940
- var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
1941
- return ReactElement(
1942
- type,
1943
- key,
1944
- i,
1945
- getOwner(),
1946
- propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
1947
- propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
1948
- );
1949
- };
1950
- exports$1.createRef = function () {
1951
- var refObject = { current: null };
1952
- Object.seal(refObject);
1953
- return refObject;
1954
- };
1955
- exports$1.forwardRef = function (render) {
1956
- null != render && render.$$typeof === REACT_MEMO_TYPE
1957
- ? console.error(
1958
- "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
1959
- )
1960
- : "function" !== typeof render
1961
- ? console.error(
1962
- "forwardRef requires a render function but was given %s.",
1963
- null === render ? "null" : typeof render
1964
- )
1965
- : 0 !== render.length &&
1966
- 2 !== render.length &&
1967
- console.error(
1968
- "forwardRef render functions accept exactly two parameters: props and ref. %s",
1969
- 1 === render.length
1970
- ? "Did you forget to use the ref parameter?"
1971
- : "Any additional parameter will be undefined."
1972
- );
1973
- null != render &&
1974
- null != render.defaultProps &&
1975
- console.error(
1976
- "forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
1977
- );
1978
- var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render: render },
1979
- ownName;
1980
- Object.defineProperty(elementType, "displayName", {
1981
- enumerable: false,
1982
- configurable: true,
1983
- get: function () {
1984
- return ownName;
1985
- },
1986
- set: function (name) {
1987
- ownName = name;
1988
- render.name ||
1989
- render.displayName ||
1990
- (Object.defineProperty(render, "name", { value: name }),
1991
- (render.displayName = name));
1992
- }
1993
- });
1994
- return elementType;
1995
- };
1996
- exports$1.isValidElement = isValidElement;
1997
- exports$1.lazy = function (ctor) {
1998
- ctor = { _status: -1, _result: ctor };
1999
- var lazyType = {
2000
- $$typeof: REACT_LAZY_TYPE,
2001
- _payload: ctor,
2002
- _init: lazyInitializer
2003
- },
2004
- ioInfo = {
2005
- name: "lazy",
2006
- start: -1,
2007
- end: -1,
2008
- value: null,
2009
- owner: null,
2010
- debugStack: Error("react-stack-top-frame"),
2011
- debugTask: console.createTask ? console.createTask("lazy()") : null
2012
- };
2013
- ctor._ioInfo = ioInfo;
2014
- lazyType._debugInfo = [{ awaited: ioInfo }];
2015
- return lazyType;
2016
- };
2017
- exports$1.memo = function (type, compare) {
2018
- null == type &&
2019
- console.error(
2020
- "memo: The first argument must be a component. Instead received: %s",
2021
- null === type ? "null" : typeof type
2022
- );
2023
- compare = {
2024
- $$typeof: REACT_MEMO_TYPE,
2025
- type: type,
2026
- compare: void 0 === compare ? null : compare
2027
- };
2028
- var ownName;
2029
- Object.defineProperty(compare, "displayName", {
2030
- enumerable: false,
2031
- configurable: true,
2032
- get: function () {
2033
- return ownName;
2034
- },
2035
- set: function (name) {
2036
- ownName = name;
2037
- type.name ||
2038
- type.displayName ||
2039
- (Object.defineProperty(type, "name", { value: name }),
2040
- (type.displayName = name));
2041
- }
2042
- });
2043
- return compare;
2044
- };
2045
- exports$1.startTransition = function (scope) {
2046
- var prevTransition = ReactSharedInternals.T,
2047
- currentTransition = {};
2048
- currentTransition._updatedFibers = new Set();
2049
- ReactSharedInternals.T = currentTransition;
2050
- try {
2051
- var returnValue = scope(),
2052
- onStartTransitionFinish = ReactSharedInternals.S;
2053
- null !== onStartTransitionFinish &&
2054
- onStartTransitionFinish(currentTransition, returnValue);
2055
- "object" === typeof returnValue &&
2056
- null !== returnValue &&
2057
- "function" === typeof returnValue.then &&
2058
- (ReactSharedInternals.asyncTransitions++,
2059
- returnValue.then(releaseAsyncTransition, releaseAsyncTransition),
2060
- returnValue.then(noop, reportGlobalError));
2061
- } catch (error) {
2062
- reportGlobalError(error);
2063
- } finally {
2064
- null === prevTransition &&
2065
- currentTransition._updatedFibers &&
2066
- ((scope = currentTransition._updatedFibers.size),
2067
- currentTransition._updatedFibers.clear(),
2068
- 10 < scope &&
2069
- console.warn(
2070
- "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
2071
- )),
2072
- null !== prevTransition &&
2073
- null !== currentTransition.types &&
2074
- (null !== prevTransition.types &&
2075
- prevTransition.types !== currentTransition.types &&
2076
- console.error(
2077
- "We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
2078
- ),
2079
- (prevTransition.types = currentTransition.types)),
2080
- (ReactSharedInternals.T = prevTransition);
2081
- }
2082
- };
2083
- exports$1.unstable_useCacheRefresh = function () {
2084
- return resolveDispatcher().useCacheRefresh();
2085
- };
2086
- exports$1.use = function (usable) {
2087
- return resolveDispatcher().use(usable);
2088
- };
2089
- exports$1.useActionState = function (action, initialState, permalink) {
2090
- return resolveDispatcher().useActionState(
2091
- action,
2092
- initialState,
2093
- permalink
2094
- );
2095
- };
2096
- exports$1.useCallback = function (callback, deps) {
2097
- return resolveDispatcher().useCallback(callback, deps);
2098
- };
2099
- exports$1.useContext = function (Context) {
2100
- var dispatcher = resolveDispatcher();
2101
- Context.$$typeof === REACT_CONSUMER_TYPE &&
2102
- console.error(
2103
- "Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
2104
- );
2105
- return dispatcher.useContext(Context);
2106
- };
2107
- exports$1.useDebugValue = function (value, formatterFn) {
2108
- return resolveDispatcher().useDebugValue(value, formatterFn);
2109
- };
2110
- exports$1.useDeferredValue = function (value, initialValue) {
2111
- return resolveDispatcher().useDeferredValue(value, initialValue);
2112
- };
2113
- exports$1.useEffect = function (create, deps) {
2114
- null == create &&
2115
- console.warn(
2116
- "React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2117
- );
2118
- return resolveDispatcher().useEffect(create, deps);
2119
- };
2120
- exports$1.useEffectEvent = function (callback) {
2121
- return resolveDispatcher().useEffectEvent(callback);
2122
- };
2123
- exports$1.useId = function () {
2124
- return resolveDispatcher().useId();
2125
- };
2126
- exports$1.useImperativeHandle = function (ref, create, deps) {
2127
- return resolveDispatcher().useImperativeHandle(ref, create, deps);
2128
- };
2129
- exports$1.useInsertionEffect = function (create, deps) {
2130
- null == create &&
2131
- console.warn(
2132
- "React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2133
- );
2134
- return resolveDispatcher().useInsertionEffect(create, deps);
2135
- };
2136
- exports$1.useLayoutEffect = function (create, deps) {
2137
- null == create &&
2138
- console.warn(
2139
- "React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2140
- );
2141
- return resolveDispatcher().useLayoutEffect(create, deps);
2142
- };
2143
- exports$1.useMemo = function (create, deps) {
2144
- return resolveDispatcher().useMemo(create, deps);
2145
- };
2146
- exports$1.useOptimistic = function (passthrough, reducer) {
2147
- return resolveDispatcher().useOptimistic(passthrough, reducer);
2148
- };
2149
- exports$1.useReducer = function (reducer, initialArg, init) {
2150
- return resolveDispatcher().useReducer(reducer, initialArg, init);
2151
- };
2152
- exports$1.useRef = function (initialValue) {
2153
- return resolveDispatcher().useRef(initialValue);
2154
- };
2155
- exports$1.useState = function (initialState) {
2156
- return resolveDispatcher().useState(initialState);
2157
- };
2158
- exports$1.useSyncExternalStore = function (
2159
- subscribe,
2160
- getSnapshot,
2161
- getServerSnapshot
2162
- ) {
2163
- return resolveDispatcher().useSyncExternalStore(
2164
- subscribe,
2165
- getSnapshot,
2166
- getServerSnapshot
2167
- );
2168
- };
2169
- exports$1.useTransition = function () {
2170
- return resolveDispatcher().useTransition();
2171
- };
2172
- exports$1.version = "19.2.4";
2173
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2174
- "function" ===
2175
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
2176
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
2177
- })();
2178
- } (react_development, react_development.exports));
2179
- return react_development.exports;
2180
- }
2181
-
2182
- var hasRequiredReact;
2183
-
2184
- function requireReact () {
2185
- if (hasRequiredReact) return react.exports;
2186
- hasRequiredReact = 1;
2187
-
2188
- if (process.env.NODE_ENV === 'production') {
2189
- react.exports = requireReact_production();
2190
- } else {
2191
- react.exports = requireReact_development();
2192
- }
2193
- return react.exports;
2194
- }
2195
-
2196
- var reactExports = requireReact();
2197
- var React = /*@__PURE__*/getDefaultExportFromCjs(reactExports);
2198
-
2199
360
  /**
2200
361
  * A React hook for managing QidCloud authentication lifecycle.
2201
362
  * Handles handshake initialization, WebSocket listeners, and profile fetching.
2202
363
  */
2203
364
  function useQidAuth(sdk) {
2204
- const [user, setUser] = reactExports.useState(null);
2205
- const [token, setToken] = reactExports.useState(null);
2206
- const [session, setSession] = reactExports.useState(null);
2207
- const [loading, setLoading] = reactExports.useState(false);
2208
- const [initializing, setInitializing] = reactExports.useState(false);
2209
- const [error, setError] = reactExports.useState(null);
365
+ const [user, setUser] = React.useState(null);
366
+ const [token, setToken] = React.useState(null);
367
+ const [session, setSession] = React.useState(null);
368
+ const [loading, setLoading] = React.useState(false);
369
+ const [initializing, setInitializing] = React.useState(false);
370
+ const [error, setError] = React.useState(null);
371
+ const [timeLeft, setTimeLeft] = React.useState(0);
372
+ const [isExpired, setIsExpired] = React.useState(false);
2210
373
  // Use ref to track if we should still be listening (to avoid state updates after unmount/cancel)
2211
- const activeSessionId = reactExports.useRef(null);
2212
- const logout = reactExports.useCallback(() => {
374
+ const activeSessionId = React.useRef(null);
375
+ const timerRef = React.useRef(null);
376
+ const clearTimer = React.useCallback(() => {
377
+ if (timerRef.current) {
378
+ clearInterval(timerRef.current);
379
+ timerRef.current = null;
380
+ }
381
+ }, []);
382
+ const STORAGE_KEY = 'qid_auth_token';
383
+ // Helper to fetch profile
384
+ const fetchProfile = React.useCallback(async (authToken) => {
385
+ setLoading(true);
386
+ try {
387
+ const profile = await sdk.auth.getProfile(authToken);
388
+ setToken(authToken);
389
+ setUser(profile);
390
+ localStorage.setItem(STORAGE_KEY, authToken);
391
+ }
392
+ catch (err) {
393
+ console.error('Failed to restore session:', err);
394
+ setError('Session expired');
395
+ localStorage.removeItem(STORAGE_KEY);
396
+ setToken(null);
397
+ setUser(null);
398
+ }
399
+ finally {
400
+ setLoading(false);
401
+ setInitializing(false);
402
+ }
403
+ }, [sdk]);
404
+ // Init: Check local storage
405
+ React.useEffect(() => {
406
+ const storedToken = localStorage.getItem(STORAGE_KEY);
407
+ if (storedToken) {
408
+ fetchProfile(storedToken);
409
+ }
410
+ }, [fetchProfile]);
411
+ const logout = React.useCallback(async () => {
412
+ if (token) {
413
+ await sdk.auth.logout(token);
414
+ }
415
+ else {
416
+ sdk.auth.disconnect();
417
+ }
418
+ localStorage.removeItem(STORAGE_KEY);
2213
419
  setUser(null);
2214
420
  setToken(null);
2215
421
  setSession(null);
2216
- sdk.auth.disconnect();
2217
- }, [sdk]);
2218
- const cancel = reactExports.useCallback(() => {
422
+ setIsExpired(false);
423
+ clearTimer();
424
+ }, [sdk, token, clearTimer]);
425
+ const cancel = React.useCallback(() => {
2219
426
  activeSessionId.current = null;
2220
427
  setSession(null);
2221
428
  setInitializing(false);
429
+ setIsExpired(false);
430
+ clearTimer();
2222
431
  sdk.auth.disconnect();
2223
- }, [sdk]);
2224
- const login = reactExports.useCallback(async () => {
432
+ }, [sdk, clearTimer]);
433
+ const login = React.useCallback(async () => {
2225
434
  setInitializing(true);
2226
435
  setError(null);
436
+ setIsExpired(false);
437
+ clearTimer();
2227
438
  try {
2228
439
  const newSession = await sdk.auth.createSession();
2229
440
  setSession(newSession);
2230
441
  activeSessionId.current = newSession.sessionId;
442
+ // Start Timer
443
+ const expiresAt = newSession.expiresAt || (Date.now() + 120000); // Fallback 2m
444
+ setTimeLeft(Math.max(0, Math.floor((expiresAt - Date.now()) / 1000)));
445
+ timerRef.current = setInterval(() => {
446
+ const remaining = Math.max(0, Math.floor((expiresAt - Date.now()) / 1000));
447
+ setTimeLeft(remaining);
448
+ if (remaining <= 0) {
449
+ setIsExpired(true);
450
+ clearTimer();
451
+ // Don't nullify session immediately, let UI show expiry state
452
+ }
453
+ }, 1000);
2231
454
  sdk.auth.listen(newSession.sessionId, async (receivedToken) => {
2232
455
  // Safety check: is this still the active session?
2233
456
  if (activeSessionId.current !== newSession.sessionId)
2234
457
  return;
2235
- setLoading(true);
2236
- setInitializing(false);
2237
- try {
2238
- const profile = await sdk.auth.getProfile(receivedToken);
2239
- setToken(receivedToken);
2240
- setUser(profile);
2241
- }
2242
- catch (err) {
2243
- setError(err.message || 'Failed to fetch user profile');
2244
- }
2245
- finally {
2246
- setLoading(false);
2247
- setSession(null);
2248
- }
458
+ clearTimer();
459
+ setSession(null); // Clear QR session
460
+ // Fetch profile and persist
461
+ await fetchProfile(receivedToken);
2249
462
  }, (err) => {
2250
463
  if (activeSessionId.current !== newSession.sessionId)
2251
464
  return;
2252
465
  setError(err);
2253
466
  setInitializing(false);
2254
467
  setSession(null);
468
+ clearTimer();
2255
469
  });
2256
470
  }
2257
471
  catch (err) {
2258
472
  setError(err.message || 'Failed to initiate login handshake');
2259
473
  setInitializing(false);
474
+ clearTimer();
2260
475
  }
2261
- }, [sdk]);
476
+ }, [sdk, clearTimer, fetchProfile]);
2262
477
  // Cleanup on unmount
2263
- reactExports.useEffect(() => {
478
+ React.useEffect(() => {
2264
479
  return () => {
480
+ clearTimer();
2265
481
  sdk.auth.disconnect();
2266
482
  };
2267
- }, [sdk]);
483
+ }, [sdk, clearTimer]);
2268
484
  return {
2269
485
  user,
2270
486
  token,
@@ -2272,17 +488,26 @@ function useQidAuth(sdk) {
2272
488
  error,
2273
489
  session,
2274
490
  initializing,
491
+ isExpired,
492
+ timeLeft,
2275
493
  login,
2276
494
  logout,
2277
- cancel
495
+ cancel,
496
+ setAuthenticated: (user, token) => {
497
+ setUser(user);
498
+ setToken(token);
499
+ localStorage.setItem(STORAGE_KEY, token);
500
+ setInitializing(false);
501
+ }
2278
502
  };
2279
503
  }
2280
504
 
2281
505
  /**
2282
506
  * A ready-to-use React component for QidCloud QR identity authentication.
2283
507
  */
2284
- const QidSignInButton = ({ sdk, onSuccess, onError, className, buttonText = 'Login with QidCloud' }) => {
2285
- const { user, token, error, session, initializing, login, cancel } = useQidAuth(sdk);
508
+ const QidSignInButton = ({ sdk, onSuccess, onError, className, buttonText = 'LOGIN WITH QIDCLOUD' }) => {
509
+ const { user, token, error, session, initializing, isExpired, timeLeft, login, cancel } = useQidAuth(sdk);
510
+ const [appError, setAppError] = React.useState(false);
2286
511
  // Watch for success
2287
512
  React.useEffect(() => {
2288
513
  if (user && token) {
@@ -2362,19 +587,42 @@ const QidSignInButton = ({ sdk, onSuccess, onError, className, buttonText = 'Log
2362
587
  marginBottom: '30px',
2363
588
  boxShadow: '0 10px 40px rgba(0,0,0,0.3)'
2364
589
  } },
2365
- React.createElement(qrcode_react.QRCodeSVG, { value: session.qrData, size: 220, level: "H", includeMargin: false, imageSettings: {
590
+ React.createElement(qrcode_react.QRCodeSVG, { value: session.qrData, size: 220, level: "H", includeMargin: false, style: { opacity: isExpired ? 0.1 : 1, transition: 'opacity 0.3s' }, imageSettings: {
2366
591
  src: "https://api.qidcloud.com/favicon.ico",
2367
592
  x: undefined,
2368
593
  y: undefined,
2369
594
  height: 40,
2370
595
  width: 40,
2371
596
  excavate: true,
2372
- } })),
2373
- React.createElement("div", { style: { display: 'flex', flexDirection: 'column', gap: '15px' } },
2374
- React.createElement("div", { style: { height: '4px', width: '60px', backgroundColor: '#00e5ff', margin: '0 auto', borderRadius: '2px', opacity: 0.5 } }),
597
+ } }),
598
+ isExpired && (React.createElement("div", { style: {
599
+ position: 'absolute',
600
+ top: '50%',
601
+ left: '50%',
602
+ transform: 'translate(-50%, -50%)',
603
+ width: '100%'
604
+ } },
605
+ React.createElement("button", { onClick: login, style: {
606
+ backgroundColor: '#00e5ff',
607
+ color: '#000',
608
+ border: 'none',
609
+ padding: '12px 20px',
610
+ borderRadius: '12px',
611
+ fontWeight: '900',
612
+ cursor: 'pointer',
613
+ boxShadow: '0 4px 15px rgba(0, 229, 255, 0.4)',
614
+ fontSize: '0.8rem'
615
+ } }, "REFRESH QR")))),
616
+ isExpired && (React.createElement("p", { style: { color: '#ef4444', fontSize: '0.85rem', marginBottom: '20px', fontWeight: '600' } }, "Session expired. Please refresh.")),
617
+ React.createElement("div", { style: { marginBottom: '20px' } },
618
+ React.createElement("p", { style: { fontSize: '0.85rem', color: '#94a3b8', marginBottom: '8px' } }, "Are you on mobile?"),
619
+ React.createElement("p", { style: { fontSize: '0.75rem', color: '#64748b' } },
620
+ "Use ",
621
+ React.createElement("strong", null, "One-Click Auth"),
622
+ " for instant access.")),
623
+ React.createElement("div", { style: { display: 'flex', gap: '12px', marginTop: '10px' } },
2375
624
  React.createElement("button", { onClick: cancel, style: {
2376
- display: 'block',
2377
- width: '100%',
625
+ flex: 2,
2378
626
  padding: '16px',
2379
627
  backgroundColor: 'transparent',
2380
628
  color: '#64748b',
@@ -2384,13 +632,71 @@ const QidSignInButton = ({ sdk, onSuccess, onError, className, buttonText = 'Log
2384
632
  fontWeight: '700',
2385
633
  transition: 'all 0.2s',
2386
634
  fontSize: '0.9rem'
2387
- } }, "Cancel Handshake")),
635
+ } }, "Cancel"),
636
+ React.createElement("button", { onClick: () => {
637
+ setAppError(false);
638
+ const deepLink = `qidcloud://authorize?sessionId=${session.sessionId}`; // Corrected format per docs
639
+ // Timeout to check if app opened
640
+ const start = Date.now();
641
+ window.location.href = deepLink;
642
+ setTimeout(() => {
643
+ if (Date.now() - start < 1500) {
644
+ setAppError(true);
645
+ }
646
+ }, 1000);
647
+ }, style: {
648
+ flex: 1,
649
+ padding: '16px',
650
+ backgroundColor: 'rgba(0, 229, 255, 0.1)',
651
+ color: '#00e5ff',
652
+ border: '1px solid rgba(0, 229, 255, 0.3)',
653
+ borderRadius: '16px',
654
+ cursor: 'pointer',
655
+ display: 'flex',
656
+ alignItems: 'center',
657
+ justifyContent: 'center',
658
+ transition: 'all 0.2s'
659
+ }, title: "Authenticate with QidCloud App" },
660
+ React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" },
661
+ React.createElement("rect", { x: "5", y: "2", width: "14", height: "20", rx: "2", ry: "2" }),
662
+ React.createElement("line", { x1: "12", y1: "18", x2: "12.01", y2: "18" })))),
663
+ appError && (React.createElement("p", { style: { color: '#f59e0b', fontSize: '0.75rem', marginTop: '12px', fontWeight: '600' } }, "QidCloud App not found on device")),
2388
664
  React.createElement("div", { style: { marginTop: '25px', fontSize: '0.75rem', color: '#475569' } },
2389
665
  "Session ID: ",
2390
666
  session.sessionId.slice(0, 8),
2391
667
  "..."))))));
2392
668
  };
2393
669
 
670
+ /**
671
+ * A comprehensive login component for QidCloud.
672
+ * STRICT SECURITY: ONLY supports QR Scanning (Mobile App) for Post-Quantum security.
673
+ * Conventional login is not available in the SDK to prevent password transmission in third-party apps.
674
+ */
675
+ const QidCloudLogin = ({ sdk, onSuccess, onError, className }) => {
676
+ return (React.createElement("div", { className: `qid-login-container ${className || ''}`, style: {
677
+ fontFamily: "'Inter', sans-serif",
678
+ maxWidth: '380px',
679
+ margin: '0 auto',
680
+ padding: '30px',
681
+ backgroundColor: '#050505',
682
+ borderRadius: '24px',
683
+ border: '1px solid #333',
684
+ boxShadow: '0 20px 80px rgba(0,0,0,0.8)',
685
+ color: '#fff',
686
+ textAlign: 'center'
687
+ } },
688
+ React.createElement("div", { style: { marginBottom: '30px' } },
689
+ React.createElement("h2", { style: { fontSize: '1.5rem', fontWeight: 700, margin: '0 0 10px 0', letterSpacing: '-0.02em' } }, "QidCloud Login"),
690
+ React.createElement("p", { style: { color: '#888', fontSize: '0.9rem', margin: 0 } }, "Secure Post-Quantum Access")),
691
+ React.createElement("div", { style: { marginBottom: '20px', padding: '10px', backgroundColor: '#111', borderRadius: '16px', border: '1px dashed #333' } },
692
+ React.createElement("p", { style: { fontSize: '0.85rem', color: '#888', marginBottom: '20px', lineHeight: '1.5' } },
693
+ "Login instantly by scanning the secure QR code with your ",
694
+ React.createElement("strong", null, "QidCloud App"),
695
+ "."),
696
+ React.createElement(QidSignInButton, { sdk: sdk, onSuccess: onSuccess, onError: onError, buttonText: "Login with QIDCLOUD", className: "qid-qr-btn-full" })),
697
+ React.createElement("p", { style: { fontSize: '0.75rem', color: '#444', marginTop: '20px' } }, "Credentials are never entered on this device.")));
698
+ };
699
+
2394
700
  class QidCloud {
2395
701
  config;
2396
702
  api;
@@ -2426,6 +732,7 @@ class QidCloud {
2426
732
  }
2427
733
 
2428
734
  exports.QidCloud = QidCloud;
735
+ exports.QidCloudLogin = QidCloudLogin;
2429
736
  exports.QidSignInButton = QidSignInButton;
2430
737
  exports.default = QidCloud;
2431
738
  exports.useQidAuth = useQidAuth;