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