@qidcloud/sdk 1.2.2 → 1.2.4

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,6 +90,145 @@ class AuthModule {
66
90
  'Authorization': `Bearer ${token}`
67
91
  }
68
92
  });
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
+ };
101
+ }
102
+ // --- Conventional Auth Methods ---
103
+ /**
104
+ * Login using username and password
105
+ */
106
+ async login(credentials) {
107
+ const resp = await this.sdk.api.post('/api/login/conventional', credentials);
108
+ return resp.data;
109
+ }
110
+ /**
111
+ * Register a new user
112
+ */
113
+ async register(data) {
114
+ const resp = await this.sdk.api.post('/api/register/conventional', data);
115
+ return resp.data;
116
+ }
117
+ /**
118
+ * Initiate registration (OTP based if configured)
119
+ */
120
+ async initiateRegistration(email) {
121
+ const resp = await this.sdk.api.post('/api/register/initiate', { email });
122
+ return resp.data;
123
+ }
124
+ /**
125
+ * Verify OTP or mobile verification
126
+ */
127
+ async verify(data) {
128
+ const resp = await this.sdk.api.post('/api/verify', data);
129
+ return resp.data;
130
+ }
131
+ // --- Password & Account Management ---
132
+ /**
133
+ * Request a password reset link/OTP
134
+ */
135
+ async requestPasswordReset(email) {
136
+ const resp = await this.sdk.api.post('/api/password/reset/request', { email });
137
+ return resp.data;
138
+ }
139
+ /**
140
+ * Confirm password reset with OTP and new password
141
+ */
142
+ async confirmPasswordReset(data) {
143
+ const resp = await this.sdk.api.post('/api/password/reset/confirm', data);
144
+ return resp.data;
145
+ }
146
+ /**
147
+ * Change current password (requires current token)
148
+ */
149
+ async changePassword(token, data) {
150
+ const resp = await this.sdk.api.post('/api/password/change', data, {
151
+ headers: { 'Authorization': `Bearer ${token}` }
152
+ });
153
+ return resp.data;
154
+ }
155
+ /**
156
+ * Delete user account
157
+ */
158
+ async deleteAccount(token) {
159
+ const resp = await this.sdk.api.delete('/api/auth/account', {
160
+ headers: { 'Authorization': `Bearer ${token}` }
161
+ });
162
+ return resp.data;
163
+ }
164
+ // --- MFA Management ---
165
+ /**
166
+ * Toggle MFA status (Enable/Disable)
167
+ */
168
+ async toggleMFA(token, data) {
169
+ const resp = await this.sdk.api.post('/api/auth/mfa/toggle', data, {
170
+ headers: { 'Authorization': `Bearer ${token}` }
171
+ });
172
+ return resp.data;
173
+ }
174
+ /**
175
+ * Verify MFA toggle request
176
+ */
177
+ async verifyMFA(token, otp) {
178
+ const resp = await this.sdk.api.post('/api/auth/mfa/verify', { otp }, {
179
+ headers: { 'Authorization': `Bearer ${token}` }
180
+ });
181
+ return resp.data;
182
+ }
183
+ // --- Session & Recovery ---
184
+ /**
185
+ * Refresh the current active session
186
+ */
187
+ async refreshSession(token) {
188
+ const resp = await this.sdk.api.post('/api/session/refresh', {}, {
189
+ headers: { 'Authorization': `Bearer ${token}` }
190
+ });
191
+ return resp.data;
192
+ }
193
+ /**
194
+ * List all active sessions for the user
195
+ */
196
+ async getSessions(token) {
197
+ const resp = await this.sdk.api.get('/api/sessions', {
198
+ headers: { 'Authorization': `Bearer ${token}` }
199
+ });
200
+ return resp.data;
201
+ }
202
+ /**
203
+ * Revoke a specific session
204
+ */
205
+ async revokeSession(token, sessionToken) {
206
+ const resp = await this.sdk.api.delete(`/api/sessions/${sessionToken}`, {
207
+ headers: { 'Authorization': `Bearer ${token}` }
208
+ });
209
+ return resp.data;
210
+ }
211
+ /**
212
+ * Initiate account recovery (password reset)
213
+ */
214
+ async initiateRecovery(email) {
215
+ const resp = await this.sdk.api.post('/api/recover', { email });
216
+ return resp.data;
217
+ }
218
+ /**
219
+ * Verify recovery OTP and set new password
220
+ */
221
+ async verifyRecovery(data) {
222
+ const resp = await this.sdk.api.post('/api/recover/verify', data);
223
+ return resp.data;
224
+ }
225
+ /**
226
+ * Export all user data (GDPR requirement)
227
+ */
228
+ async exportUserData(token) {
229
+ const resp = await this.sdk.api.get('/api/auth/account/export', {
230
+ headers: { 'Authorization': `Bearer ${token}` }
231
+ });
69
232
  return resp.data;
70
233
  }
71
234
  }
@@ -101,6 +264,98 @@ class DbModule {
101
264
  const resp = await this.sdk.api.post('/api/db/setup', {}, { headers });
102
265
  return resp.data;
103
266
  }
267
+ /**
268
+ * Run versioned migrations (Django-inspired).
269
+ * Only applies migrations that haven't been applied yet.
270
+ * Tracks applied migrations in a `_qid_migrations` table.
271
+ *
272
+ * @example
273
+ * ```ts
274
+ * await qid.db.migrate([
275
+ * { version: '001', name: 'create_users', up: async () => { await qid.db.query('CREATE TABLE ...') } },
276
+ * { version: '002', name: 'add_likes', up: async () => { await qid.db.query('ALTER TABLE ...') } },
277
+ * ]);
278
+ * ```
279
+ *
280
+ * @param migrations Ordered array of migrations to apply
281
+ * @param userToken Optional session token
282
+ * @returns Result with applied/skipped counts
283
+ */
284
+ async migrate(migrations, userToken) {
285
+ const result = {
286
+ success: true,
287
+ applied: [],
288
+ skipped: [],
289
+ total: migrations.length,
290
+ };
291
+ try {
292
+ // 1. Ensure the migrations tracking table exists
293
+ await this.query(`CREATE TABLE IF NOT EXISTS _qid_migrations (
294
+ version VARCHAR(50) PRIMARY KEY,
295
+ name VARCHAR(255) NOT NULL,
296
+ applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
297
+ )`, [], userToken);
298
+ // 2. Get already-applied migrations
299
+ const appliedRes = await this.query('SELECT version FROM _qid_migrations ORDER BY version', [], userToken);
300
+ const appliedVersions = new Set((appliedRes.data || []).map((r) => r.version));
301
+ // 3. Run only new migrations, in order
302
+ for (const migration of migrations) {
303
+ if (appliedVersions.has(migration.version)) {
304
+ result.skipped.push(migration.version);
305
+ continue;
306
+ }
307
+ try {
308
+ await migration.up();
309
+ // Record as applied
310
+ await this.query('INSERT INTO _qid_migrations (version, name) VALUES ($1, $2) ON CONFLICT (version) DO NOTHING', [migration.version, migration.name], userToken);
311
+ result.applied.push(migration.version);
312
+ }
313
+ catch (migrationError) {
314
+ result.success = false;
315
+ result.failed = {
316
+ version: migration.version,
317
+ error: migrationError.message || 'Unknown error',
318
+ };
319
+ // Stop on first failure (like Django)
320
+ break;
321
+ }
322
+ }
323
+ return result;
324
+ }
325
+ catch (err) {
326
+ return {
327
+ success: false,
328
+ applied: result.applied,
329
+ skipped: result.skipped,
330
+ failed: { version: 'init', error: err.message || 'Migration system init failed' },
331
+ total: migrations.length,
332
+ };
333
+ }
334
+ }
335
+ /**
336
+ * Get the current migration status
337
+ * @param migrations The full list of registered migrations
338
+ * @param userToken Optional session token
339
+ */
340
+ async migrateStatus(migrations, userToken) {
341
+ try {
342
+ const appliedRes = await this.query('SELECT version FROM _qid_migrations ORDER BY version', [], userToken);
343
+ const appliedVersions = new Set((appliedRes.data || []).map((r) => r.version));
344
+ return {
345
+ applied: migrations.filter(m => appliedVersions.has(m.version)).map(m => m.version),
346
+ pending: migrations.filter(m => !appliedVersions.has(m.version)).map(m => m.version),
347
+ total: migrations.length,
348
+ };
349
+ }
350
+ catch {
351
+ // Table doesn't exist yet = all pending
352
+ return {
353
+ applied: [],
354
+ pending: migrations.map(m => m.version),
355
+ total: migrations.length,
356
+ };
357
+ }
358
+ }
104
359
  }
105
360
 
106
361
  class EdgeModule {
@@ -194,19 +449,38 @@ class EdgeModule {
194
449
  }
195
450
  }
196
451
 
452
+ const DEFAULT_CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
453
+ const CHUNKED_THRESHOLD = 10 * 1024 * 1024; // 10MB — above this, use chunked upload
197
454
  class VaultModule {
198
455
  sdk;
199
456
  constructor(sdk) {
200
457
  this.sdk = sdk;
201
458
  }
202
459
  /**
203
- * Upload a file to the project's secure enclave storage
204
- * @param file The file data (Buffer or Blob)
460
+ * Upload a file to the project's secure enclave storage.
461
+ *
462
+ * Files < 10MB use single-shot upload.
463
+ * Files >= 10MB automatically use chunked upload with progress tracking.
464
+ *
465
+ * @param file The file data (Buffer, Blob, or File)
205
466
  * @param fileName Name of the file
206
467
  * @param metadata Optional E2EE metadata or custom tags
207
468
  * @param userToken Session token for user-scoped storage
469
+ * @param options Upload options (onProgress callback, custom chunk size)
208
470
  */
209
- async upload(file, fileName, metadata = {}, userToken) {
471
+ async upload(file, fileName, metadata = {}, userToken, options) {
472
+ const fileSize = file.size || file.length || file.byteLength || 0;
473
+ // Auto-detect: use chunked upload for large files
474
+ if (fileSize >= CHUNKED_THRESHOLD) {
475
+ return this._chunkedUpload(file, fileName, fileSize, metadata, userToken, options);
476
+ }
477
+ // Small file — single-shot upload (existing behavior)
478
+ return this._singleUpload(file, fileName, metadata, userToken);
479
+ }
480
+ /**
481
+ * Single-shot upload for small files (< 10MB)
482
+ */
483
+ async _singleUpload(file, fileName, metadata, userToken) {
210
484
  const formData = new FormData();
211
485
  formData.append('file', file, fileName);
212
486
  formData.append('metadata', JSON.stringify(metadata));
@@ -219,9 +493,149 @@ class VaultModule {
219
493
  const resp = await this.sdk.api.post('/api/storage/upload', formData, { headers });
220
494
  return resp.data;
221
495
  }
496
+ /**
497
+ * Chunked upload for large files (>= 10MB)
498
+ * Flow: init → upload chunks → complete
499
+ */
500
+ async _chunkedUpload(file, fileName, fileSize, metadata, userToken, options) {
501
+ const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE;
502
+ const totalChunks = Math.ceil(fileSize / chunkSize);
503
+ const onProgress = options?.onProgress;
504
+ const headers = {};
505
+ if (userToken) {
506
+ headers['Authorization'] = `Bearer ${userToken}`;
507
+ }
508
+ // 1. Initialize upload session
509
+ const initResp = await this.sdk.api.post('/api/storage/upload/init', {
510
+ fileName,
511
+ fileSize,
512
+ mimeType: file.type || 'application/octet-stream',
513
+ totalChunks,
514
+ metadata
515
+ }, { headers });
516
+ const { uploadId } = initResp.data;
517
+ let uploadedChunks = 0;
518
+ // 2. Upload chunks sequentially
519
+ for (let i = 0; i < totalChunks; i++) {
520
+ const start = i * chunkSize;
521
+ const end = Math.min(start + chunkSize, fileSize);
522
+ // Slice the chunk from the file
523
+ let chunkData;
524
+ if (file.slice) {
525
+ // Blob or File object
526
+ chunkData = file.slice(start, end);
527
+ }
528
+ else if (file.subarray) {
529
+ // Buffer or Uint8Array
530
+ chunkData = file.subarray(start, end);
531
+ }
532
+ else if (typeof file === 'object' && file.data) {
533
+ // express-fileupload style
534
+ chunkData = file.data.subarray(start, end);
535
+ }
536
+ // Build FormData for this chunk
537
+ const chunkForm = new FormData();
538
+ const chunkBlob = chunkData instanceof Blob ? chunkData : new Blob([chunkData]);
539
+ chunkForm.append('chunk', chunkBlob, `chunk_${i}`);
540
+ await this.sdk.api.put(`/api/storage/upload/${uploadId}/chunk/${i}`, chunkForm, {
541
+ headers: {
542
+ ...headers,
543
+ 'Content-Type': 'multipart/form-data'
544
+ }
545
+ });
546
+ uploadedChunks++;
547
+ // Report progress
548
+ if (onProgress) {
549
+ onProgress({
550
+ percent: Math.round((uploadedChunks / totalChunks) * 100),
551
+ uploadedChunks,
552
+ totalChunks,
553
+ uploadedBytes: Math.min(uploadedChunks * chunkSize, fileSize),
554
+ totalBytes: fileSize
555
+ });
556
+ }
557
+ }
558
+ // 3. Complete upload — server reassembles, encrypts, stores
559
+ const completeResp = await this.sdk.api.post(`/api/storage/upload/${uploadId}/complete`, { metadata }, { headers });
560
+ // Final 100% progress
561
+ if (onProgress) {
562
+ onProgress({
563
+ percent: 100,
564
+ uploadedChunks: totalChunks,
565
+ totalChunks,
566
+ uploadedBytes: fileSize,
567
+ totalBytes: fileSize
568
+ });
569
+ }
570
+ return completeResp.data;
571
+ }
572
+ /**
573
+ * Get the status of a chunked upload (for resume support)
574
+ */
575
+ async getUploadStatus(uploadId, userToken) {
576
+ const headers = {};
577
+ if (userToken) {
578
+ headers['Authorization'] = `Bearer ${userToken}`;
579
+ }
580
+ const resp = await this.sdk.api.get(`/api/storage/upload/${uploadId}/status`, { headers });
581
+ return resp.data;
582
+ }
583
+ /**
584
+ * Resume a partially completed chunked upload
585
+ */
586
+ async resumeUpload(uploadId, file, userToken, options) {
587
+ const headers = {};
588
+ if (userToken) {
589
+ headers['Authorization'] = `Bearer ${userToken}`;
590
+ }
591
+ // Get current status to find missing chunks
592
+ const status = await this.getUploadStatus(uploadId, userToken);
593
+ if (status.status !== 'uploading') {
594
+ throw new Error(`Upload is in "${status.status}" state and cannot be resumed`);
595
+ }
596
+ const chunkSize = options?.chunkSize || status.chunkSize || DEFAULT_CHUNK_SIZE;
597
+ const onProgress = options?.onProgress;
598
+ const missingChunks = status.missingChunks;
599
+ const totalChunks = status.totalChunks;
600
+ const fileSize = status.fileSize;
601
+ let uploadedChunks = status.receivedChunks.length;
602
+ // Upload only the missing chunks
603
+ for (const i of missingChunks) {
604
+ const start = i * chunkSize;
605
+ const end = Math.min(start + chunkSize, fileSize);
606
+ let chunkData;
607
+ if (file.slice) {
608
+ chunkData = file.slice(start, end);
609
+ }
610
+ else if (file.subarray) {
611
+ chunkData = file.subarray(start, end);
612
+ }
613
+ const chunkForm = new FormData();
614
+ const chunkBlob = chunkData instanceof Blob ? chunkData : new Blob([chunkData]);
615
+ chunkForm.append('chunk', chunkBlob, `chunk_${i}`);
616
+ await this.sdk.api.put(`/api/storage/upload/${uploadId}/chunk/${i}`, chunkForm, {
617
+ headers: {
618
+ ...headers,
619
+ 'Content-Type': 'multipart/form-data'
620
+ }
621
+ });
622
+ uploadedChunks++;
623
+ if (onProgress) {
624
+ onProgress({
625
+ percent: Math.round((uploadedChunks / totalChunks) * 100),
626
+ uploadedChunks,
627
+ totalChunks,
628
+ uploadedBytes: Math.min(uploadedChunks * chunkSize, fileSize),
629
+ totalBytes: fileSize
630
+ });
631
+ }
632
+ }
633
+ // Complete
634
+ const completeResp = await this.sdk.api.post(`/api/storage/upload/${uploadId}/complete`, {}, { headers });
635
+ return completeResp.data;
636
+ }
222
637
  /**
223
638
  * List files in the project enclave
224
- * @param userToken Session token for user-scoped storage
225
639
  */
226
640
  async list(userToken) {
227
641
  const headers = {};
@@ -233,8 +647,6 @@ class VaultModule {
233
647
  }
234
648
  /**
235
649
  * Download a file from storage
236
- * @param fileId Unique ID of the file
237
- * @param userToken Session token for user-scoped storage
238
650
  */
239
651
  async download(fileId, userToken) {
240
652
  const headers = {};
@@ -249,8 +661,6 @@ class VaultModule {
249
661
  }
250
662
  /**
251
663
  * Delete a file from storage (Soft Delete)
252
- * @param fileId Unique ID of the file
253
- * @param userToken Session token for user-scoped storage
254
664
  */
255
665
  async delete(fileId, userToken) {
256
666
  const headers = {};
@@ -262,7 +672,6 @@ class VaultModule {
262
672
  }
263
673
  /**
264
674
  * List deleted files in the project enclave (Recycle Bin)
265
- * @param userToken Session token for user-scoped storage
266
675
  */
267
676
  async listDeleted(userToken) {
268
677
  const headers = {};
@@ -274,8 +683,6 @@ class VaultModule {
274
683
  }
275
684
  /**
276
685
  * Restore a deleted file from the recycle bin
277
- * @param fileId Unique ID of the file
278
- * @param userToken Session token for user-scoped storage
279
686
  */
280
687
  async restore(fileId, userToken) {
281
688
  const headers = {};
@@ -287,8 +694,6 @@ class VaultModule {
287
694
  }
288
695
  /**
289
696
  * Permanently purge a deleted file
290
- * @param fileId Unique ID of the file
291
- * @param userToken Session token for user-scoped storage
292
697
  */
293
698
  async purge(fileId, userToken) {
294
699
  const headers = {};
@@ -326,1945 +731,465 @@ class LogsModule {
326
731
  }
327
732
  }
328
733
 
329
- function getDefaultExportFromCjs (x) {
330
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
734
+ class ProjectModule {
735
+ sdk;
736
+ constructor(sdk) {
737
+ this.sdk = sdk;
738
+ }
739
+ /**
740
+ * Get all projects owned by the currently authenticated user
741
+ */
742
+ async getMyProjects(userToken) {
743
+ const resp = await this.sdk.api.get('/api/projects/my-projects', {
744
+ headers: { 'Authorization': `Bearer ${userToken}` }
745
+ });
746
+ return resp.data;
747
+ }
748
+ /**
749
+ * Create a new project
750
+ */
751
+ async createProject(userToken, data) {
752
+ const resp = await this.sdk.api.post('/api/projects', data, {
753
+ headers: { 'Authorization': `Bearer ${userToken}` }
754
+ });
755
+ return resp.data;
756
+ }
757
+ /**
758
+ * Update project basic details (e.g. rename)
759
+ */
760
+ async updateProject(userToken, tenantId, data) {
761
+ const resp = await this.sdk.api.patch(`/api/projects/${tenantId}`, data, {
762
+ headers: { 'Authorization': `Bearer ${userToken}` }
763
+ });
764
+ return resp.data;
765
+ }
766
+ /**
767
+ * Rotate the API key for a project
768
+ */
769
+ async rotateApiKey(userToken, tenantId) {
770
+ const resp = await this.sdk.api.post(`/api/projects/${tenantId}/rotate-key`, {}, {
771
+ headers: { 'Authorization': `Bearer ${userToken}` }
772
+ });
773
+ return resp.data;
774
+ }
775
+ /**
776
+ * Get project specific settings
777
+ */
778
+ async getSettings(userToken, tenantId) {
779
+ const resp = await this.sdk.api.get(`/api/projects/${tenantId}/settings`, {
780
+ headers: { 'Authorization': `Bearer ${userToken}` }
781
+ });
782
+ return resp.data;
783
+ }
784
+ /**
785
+ * Update project settings
786
+ */
787
+ async updateSettings(userToken, tenantId, settings) {
788
+ const resp = await this.sdk.api.patch(`/api/projects/${tenantId}/settings`, settings, {
789
+ headers: { 'Authorization': `Bearer ${userToken}` }
790
+ });
791
+ return resp.data;
792
+ }
793
+ /**
794
+ * Invite a new member to the project
795
+ */
796
+ async inviteMember(userToken, tenantId, data) {
797
+ const resp = await this.sdk.api.post(`/api/projects/${tenantId}/invite`, data, {
798
+ headers: { 'Authorization': `Bearer ${userToken}` }
799
+ });
800
+ return resp.data;
801
+ }
802
+ /**
803
+ * Remove a member from the project
804
+ */
805
+ async removeMember(userToken, tenantId, userId) {
806
+ const resp = await this.sdk.api.delete(`/api/projects/${tenantId}/members/${userId}`, {
807
+ headers: { 'Authorization': `Bearer ${userToken}` }
808
+ });
809
+ return resp.data;
810
+ }
811
+ /**
812
+ * Get all users/members associated with a project
813
+ */
814
+ async getProjectUsers(userToken, tenantId) {
815
+ const resp = await this.sdk.api.get(`/api/projects/${tenantId}/users`, {
816
+ headers: { 'Authorization': `Bearer ${userToken}` }
817
+ });
818
+ return resp.data;
819
+ }
820
+ /**
821
+ * Get all invitations for the currently authenticated user
822
+ */
823
+ async getMyInvitations(userToken) {
824
+ const resp = await this.sdk.api.get('/api/projects/invitations', {
825
+ headers: { 'Authorization': `Bearer ${userToken}` }
826
+ });
827
+ return resp.data;
828
+ }
829
+ /**
830
+ * Accept or reject a project invitation
831
+ */
832
+ async handleInvitationAction(userToken, tenantId, action) {
833
+ const resp = await this.sdk.api.post(`/api/projects/${tenantId}/invitations/${action}`, {}, {
834
+ headers: { 'Authorization': `Bearer ${userToken}` }
835
+ });
836
+ return resp.data;
837
+ }
838
+ /**
839
+ * Update a member's permissions within a project
840
+ */
841
+ async updateMemberPermissions(userToken, tenantId, userId, permissions) {
842
+ const resp = await this.sdk.api.patch(`/api/projects/${tenantId}/members/${userId}/permissions`, { permissions }, {
843
+ headers: { 'Authorization': `Bearer ${userToken}` }
844
+ });
845
+ return resp.data;
846
+ }
847
+ /**
848
+ * Update a project user's status (active/suspended)
849
+ */
850
+ async updateProjectUserStatus(userToken, tenantId, regUserId, status) {
851
+ const resp = await this.sdk.api.patch(`/api/projects/${tenantId}/users/${regUserId}/status`, { status }, {
852
+ headers: { 'Authorization': `Bearer ${userToken}` }
853
+ });
854
+ return resp.data;
855
+ }
856
+ /**
857
+ * Unlink/Remove a user from the project identity enclave
858
+ */
859
+ async unlinkProjectUser(userToken, tenantId, regUserId) {
860
+ const resp = await this.sdk.api.delete(`/api/projects/${tenantId}/users/${regUserId}`, {
861
+ headers: { 'Authorization': `Bearer ${userToken}` }
862
+ });
863
+ return resp.data;
864
+ }
865
+ /**
866
+ * Generate a new service key for the project
867
+ */
868
+ async generateServiceKey(userToken, tenantId, data) {
869
+ const resp = await this.sdk.api.post(`/api/projects/${tenantId}/service-keys`, data, {
870
+ headers: { 'Authorization': `Bearer ${userToken}` }
871
+ });
872
+ return resp.data;
873
+ }
874
+ /**
875
+ * Revoke an existing service key
876
+ */
877
+ async revokeServiceKey(userToken, tenantId, keyId) {
878
+ const resp = await this.sdk.api.delete(`/api/projects/${tenantId}/service-keys/${keyId}`, {
879
+ headers: { 'Authorization': `Bearer ${userToken}` }
880
+ });
881
+ return resp.data;
882
+ }
883
+ /**
884
+ * Permanently wipe the project's identity enclave data
885
+ */
886
+ async wipeProjectEnclave(userToken, tenantId) {
887
+ const resp = await this.sdk.api.post(`/api/projects/${tenantId}/wipe`, {}, {
888
+ headers: { 'Authorization': `Bearer ${userToken}` }
889
+ });
890
+ return resp.data;
891
+ }
892
+ /**
893
+ * Retrieve security and audit logs for the project
894
+ */
895
+ async getProjectSecurityLogs(userToken, tenantId) {
896
+ const resp = await this.sdk.api.get(`/api/projects/${tenantId}/logs`, {
897
+ headers: { 'Authorization': `Bearer ${userToken}` }
898
+ });
899
+ return resp.data;
900
+ }
331
901
  }
332
902
 
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;
903
+ class ResourceModule {
904
+ sdk;
905
+ constructor(sdk) {
906
+ this.sdk = sdk;
907
+ }
908
+ /**
909
+ * Get the status of all resources for a specific tenant
910
+ */
911
+ async getStatus(userToken, tenantId) {
912
+ const resp = await this.sdk.api.get(`/api/resources/${tenantId}`, {
913
+ headers: { 'Authorization': `Bearer ${userToken}` }
914
+ });
915
+ return resp.data;
916
+ }
917
+ /**
918
+ * Provision a new resource type for a project
919
+ * @param resourceType 'database' | 'storage' | 'edge'
920
+ */
921
+ async provision(userToken, tenantId, resourceType) {
922
+ const resp = await this.sdk.api.post(`/api/resources/${tenantId}/provision/${resourceType}`, {}, {
923
+ headers: { 'Authorization': `Bearer ${userToken}` }
924
+ });
925
+ return resp.data;
926
+ }
927
+ /**
928
+ * Dissolve (delete) an existing resource from a project
929
+ */
930
+ async dissolve(userToken, tenantId, resourceType) {
931
+ const resp = await this.sdk.api.delete(`/api/resources/${tenantId}/provision/${resourceType}`, {
932
+ headers: { 'Authorization': `Bearer ${userToken}` }
933
+ });
934
+ return resp.data;
935
+ }
884
936
  }
885
937
 
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;
938
+ class SdkModule {
939
+ sdk;
940
+ constructor(sdk) {
941
+ this.sdk = sdk;
942
+ }
943
+ /**
944
+ * Get allowed origins for a project
945
+ */
946
+ async getOrigins(userToken, tenantId) {
947
+ const resp = await this.sdk.api.get(`/api/sdk/${tenantId}/origins`, {
948
+ headers: { 'Authorization': `Bearer ${userToken}` }
949
+ });
950
+ return resp.data;
951
+ }
952
+ /**
953
+ * Add an allowed origin for SDK requests
954
+ */
955
+ async addOrigin(userToken, tenantId, domain) {
956
+ const resp = await this.sdk.api.post(`/api/sdk/${tenantId}/origins`, { domain }, {
957
+ headers: { 'Authorization': `Bearer ${userToken}` }
958
+ });
959
+ return resp.data;
960
+ }
961
+ /**
962
+ * Remove an allowed origin
963
+ */
964
+ async removeOrigin(userToken, tenantId, domain) {
965
+ const resp = await this.sdk.api.delete(`/api/sdk/${tenantId}/origins/${domain}`, {
966
+ headers: { 'Authorization': `Bearer ${userToken}` }
967
+ });
968
+ return resp.data;
969
+ }
970
+ /**
971
+ * Test if an origin is allowed
972
+ */
973
+ async testOrigin(userToken, tenantId, domain) {
974
+ const resp = await this.sdk.api.post(`/api/sdk/${tenantId}/origins/test`, { domain }, {
975
+ headers: { 'Authorization': `Bearer ${userToken}` }
976
+ });
977
+ return resp.data;
978
+ }
2180
979
  }
2181
980
 
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;
981
+ class BillingModule {
982
+ sdk;
983
+ constructor(sdk) {
984
+ this.sdk = sdk;
985
+ }
986
+ /**
987
+ * Retrieve all available plans and their pricing
988
+ */
989
+ async getPlans() {
990
+ const resp = await this.sdk.api.get('/api/billing/plans');
991
+ return resp.data;
992
+ }
993
+ /**
994
+ * Get detailed billing and usage info for a project
995
+ */
996
+ async getProjectBillingInfo(userToken, tenantId) {
997
+ const resp = await this.sdk.api.get(`/api/billing/${tenantId}`, {
998
+ headers: { 'Authorization': `Bearer ${userToken}` }
999
+ });
1000
+ return resp.data;
1001
+ }
1002
+ /**
1003
+ * Sync payment status after a successful Razorpay transaction
1004
+ * @param paymentId The Razorpay payment ID
1005
+ */
1006
+ async syncPaymentStatus(userToken, paymentId) {
1007
+ const resp = await this.sdk.api.post('/api/billing/sync', { paymentId }, {
1008
+ headers: { 'Authorization': `Bearer ${userToken}` }
1009
+ });
1010
+ return resp.data;
1011
+ }
1012
+ /**
1013
+ * Get transaction history for the current user
1014
+ */
1015
+ async getTransactions(userToken) {
1016
+ const resp = await this.sdk.api.get('/api/billing/history/transactions', {
1017
+ headers: { 'Authorization': `Bearer ${userToken}` }
1018
+ });
1019
+ return resp.data;
1020
+ }
1021
+ /**
1022
+ * Get usage analytics and history
1023
+ */
1024
+ async getUsageAnalytics(userToken) {
1025
+ const resp = await this.sdk.api.get('/api/billing/history/analytics', {
1026
+ headers: { 'Authorization': `Bearer ${userToken}` }
1027
+ });
1028
+ return resp.data;
1029
+ }
1030
+ /**
1031
+ * Get billing alerts for a specific project
1032
+ */
1033
+ async getBillingAlerts(userToken, tenantId) {
1034
+ const resp = await this.sdk.api.get(`/api/billing/${tenantId}/alerts`, {
1035
+ headers: { 'Authorization': `Bearer ${userToken}` }
1036
+ });
1037
+ return resp.data;
1038
+ }
1039
+ /**
1040
+ * Create or update a billing alert
1041
+ */
1042
+ async createBillingAlert(userToken, tenantId, data) {
1043
+ const resp = await this.sdk.api.post(`/api/billing/${tenantId}/alerts`, data, {
1044
+ headers: { 'Authorization': `Bearer ${userToken}` }
1045
+ });
1046
+ return resp.data;
1047
+ }
1048
+ /**
1049
+ * Delete a billing alert
1050
+ */
1051
+ async deleteBillingAlert(userToken, alertId) {
1052
+ const resp = await this.sdk.api.delete(`/api/billing/alerts/${alertId}`, {
1053
+ headers: { 'Authorization': `Bearer ${userToken}` }
1054
+ });
1055
+ return resp.data;
1056
+ }
1057
+ /**
1058
+ * Generate a consolidated financial report
1059
+ */
1060
+ async getConsolidatedReport(userToken, query) {
1061
+ const resp = await this.sdk.api.get('/api/billing/report/consolidated', {
1062
+ params: query,
1063
+ headers: { 'Authorization': `Bearer ${userToken}` }
1064
+ });
1065
+ return resp.data;
1066
+ }
2194
1067
  }
2195
1068
 
2196
- var reactExports = requireReact();
2197
- var React = /*@__PURE__*/getDefaultExportFromCjs(reactExports);
2198
-
2199
1069
  /**
2200
1070
  * A React hook for managing QidCloud authentication lifecycle.
2201
1071
  * Handles handshake initialization, WebSocket listeners, and profile fetching.
2202
1072
  */
2203
1073
  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);
1074
+ const [user, setUser] = React.useState(null);
1075
+ const [token, setToken] = React.useState(null);
1076
+ const [session, setSession] = React.useState(null);
1077
+ const [loading, setLoading] = React.useState(false);
1078
+ const [initializing, setInitializing] = React.useState(false);
1079
+ const [error, setError] = React.useState(null);
1080
+ const [timeLeft, setTimeLeft] = React.useState(0);
1081
+ const [isExpired, setIsExpired] = React.useState(false);
2210
1082
  // 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(() => {
1083
+ const activeSessionId = React.useRef(null);
1084
+ const timerRef = React.useRef(null);
1085
+ const clearTimer = React.useCallback(() => {
1086
+ if (timerRef.current) {
1087
+ clearInterval(timerRef.current);
1088
+ timerRef.current = null;
1089
+ }
1090
+ }, []);
1091
+ const STORAGE_KEY = 'qid_auth_token';
1092
+ // Helper to fetch profile
1093
+ const fetchProfile = React.useCallback(async (authToken) => {
1094
+ setLoading(true);
1095
+ try {
1096
+ const profile = await sdk.auth.getProfile(authToken);
1097
+ setToken(authToken);
1098
+ setUser(profile);
1099
+ localStorage.setItem(STORAGE_KEY, authToken);
1100
+ }
1101
+ catch (err) {
1102
+ console.error('Failed to restore session:', err);
1103
+ setError('Session expired');
1104
+ localStorage.removeItem(STORAGE_KEY);
1105
+ setToken(null);
1106
+ setUser(null);
1107
+ }
1108
+ finally {
1109
+ setLoading(false);
1110
+ setInitializing(false);
1111
+ }
1112
+ }, [sdk]);
1113
+ // Init: Check local storage
1114
+ React.useEffect(() => {
1115
+ const storedToken = localStorage.getItem(STORAGE_KEY);
1116
+ if (storedToken) {
1117
+ fetchProfile(storedToken);
1118
+ }
1119
+ }, [fetchProfile]);
1120
+ const logout = React.useCallback(async () => {
1121
+ if (token) {
1122
+ await sdk.auth.logout(token);
1123
+ }
1124
+ else {
1125
+ sdk.auth.disconnect();
1126
+ }
1127
+ localStorage.removeItem(STORAGE_KEY);
2213
1128
  setUser(null);
2214
1129
  setToken(null);
2215
1130
  setSession(null);
2216
- sdk.auth.disconnect();
2217
- }, [sdk]);
2218
- const cancel = reactExports.useCallback(() => {
1131
+ setIsExpired(false);
1132
+ clearTimer();
1133
+ }, [sdk, token, clearTimer]);
1134
+ const cancel = React.useCallback(() => {
2219
1135
  activeSessionId.current = null;
2220
1136
  setSession(null);
2221
1137
  setInitializing(false);
1138
+ setIsExpired(false);
1139
+ clearTimer();
2222
1140
  sdk.auth.disconnect();
2223
- }, [sdk]);
2224
- const login = reactExports.useCallback(async () => {
1141
+ }, [sdk, clearTimer]);
1142
+ const login = React.useCallback(async () => {
2225
1143
  setInitializing(true);
2226
1144
  setError(null);
1145
+ setIsExpired(false);
1146
+ clearTimer();
2227
1147
  try {
2228
1148
  const newSession = await sdk.auth.createSession();
2229
1149
  setSession(newSession);
2230
1150
  activeSessionId.current = newSession.sessionId;
1151
+ // Start Timer
1152
+ const expiresAt = newSession.expiresAt || (Date.now() + 120000); // Fallback 2m
1153
+ setTimeLeft(Math.max(0, Math.floor((expiresAt - Date.now()) / 1000)));
1154
+ timerRef.current = setInterval(() => {
1155
+ const remaining = Math.max(0, Math.floor((expiresAt - Date.now()) / 1000));
1156
+ setTimeLeft(remaining);
1157
+ if (remaining <= 0) {
1158
+ setIsExpired(true);
1159
+ clearTimer();
1160
+ // Don't nullify session immediately, let UI show expiry state
1161
+ }
1162
+ }, 1000);
2231
1163
  sdk.auth.listen(newSession.sessionId, async (receivedToken) => {
2232
1164
  // Safety check: is this still the active session?
2233
1165
  if (activeSessionId.current !== newSession.sessionId)
2234
1166
  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
- }
1167
+ clearTimer();
1168
+ setSession(null); // Clear QR session
1169
+ // Fetch profile and persist
1170
+ await fetchProfile(receivedToken);
2249
1171
  }, (err) => {
2250
1172
  if (activeSessionId.current !== newSession.sessionId)
2251
1173
  return;
2252
1174
  setError(err);
2253
1175
  setInitializing(false);
2254
1176
  setSession(null);
1177
+ clearTimer();
2255
1178
  });
2256
1179
  }
2257
1180
  catch (err) {
2258
1181
  setError(err.message || 'Failed to initiate login handshake');
2259
1182
  setInitializing(false);
1183
+ clearTimer();
2260
1184
  }
2261
- }, [sdk]);
1185
+ }, [sdk, clearTimer, fetchProfile]);
2262
1186
  // Cleanup on unmount
2263
- reactExports.useEffect(() => {
1187
+ React.useEffect(() => {
2264
1188
  return () => {
1189
+ clearTimer();
2265
1190
  sdk.auth.disconnect();
2266
1191
  };
2267
- }, [sdk]);
1192
+ }, [sdk, clearTimer]);
2268
1193
  return {
2269
1194
  user,
2270
1195
  token,
@@ -2272,17 +1197,26 @@ function useQidAuth(sdk) {
2272
1197
  error,
2273
1198
  session,
2274
1199
  initializing,
1200
+ isExpired,
1201
+ timeLeft,
2275
1202
  login,
2276
1203
  logout,
2277
- cancel
1204
+ cancel,
1205
+ setAuthenticated: (user, token) => {
1206
+ setUser(user);
1207
+ setToken(token);
1208
+ localStorage.setItem(STORAGE_KEY, token);
1209
+ setInitializing(false);
1210
+ }
2278
1211
  };
2279
1212
  }
2280
1213
 
2281
1214
  /**
2282
1215
  * A ready-to-use React component for QidCloud QR identity authentication.
2283
1216
  */
2284
- const QidSignInButton = ({ sdk, onSuccess, onError, className, buttonText = 'Login with QidCloud' }) => {
2285
- const { user, token, error, session, initializing, login, cancel } = useQidAuth(sdk);
1217
+ const QidSignInButton = ({ sdk, onSuccess, onError, className, buttonText = 'LOGIN WITH QIDCLOUD' }) => {
1218
+ const { user, token, error, session, initializing, isExpired, timeLeft, login, cancel } = useQidAuth(sdk);
1219
+ const [appError, setAppError] = React.useState(false);
2286
1220
  // Watch for success
2287
1221
  React.useEffect(() => {
2288
1222
  if (user && token) {
@@ -2362,19 +1296,42 @@ const QidSignInButton = ({ sdk, onSuccess, onError, className, buttonText = 'Log
2362
1296
  marginBottom: '30px',
2363
1297
  boxShadow: '0 10px 40px rgba(0,0,0,0.3)'
2364
1298
  } },
2365
- React.createElement(qrcode_react.QRCodeSVG, { value: session.qrData, size: 220, level: "H", includeMargin: false, imageSettings: {
1299
+ 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
1300
  src: "https://api.qidcloud.com/favicon.ico",
2367
1301
  x: undefined,
2368
1302
  y: undefined,
2369
1303
  height: 40,
2370
1304
  width: 40,
2371
1305
  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 } }),
1306
+ } }),
1307
+ isExpired && (React.createElement("div", { style: {
1308
+ position: 'absolute',
1309
+ top: '50%',
1310
+ left: '50%',
1311
+ transform: 'translate(-50%, -50%)',
1312
+ width: '100%'
1313
+ } },
1314
+ React.createElement("button", { onClick: login, style: {
1315
+ backgroundColor: '#00e5ff',
1316
+ color: '#000',
1317
+ border: 'none',
1318
+ padding: '12px 20px',
1319
+ borderRadius: '12px',
1320
+ fontWeight: '900',
1321
+ cursor: 'pointer',
1322
+ boxShadow: '0 4px 15px rgba(0, 229, 255, 0.4)',
1323
+ fontSize: '0.8rem'
1324
+ } }, "REFRESH QR")))),
1325
+ isExpired && (React.createElement("p", { style: { color: '#ef4444', fontSize: '0.85rem', marginBottom: '20px', fontWeight: '600' } }, "Session expired. Please refresh.")),
1326
+ React.createElement("div", { style: { marginBottom: '20px' } },
1327
+ React.createElement("p", { style: { fontSize: '0.85rem', color: '#94a3b8', marginBottom: '8px' } }, "Are you on mobile?"),
1328
+ React.createElement("p", { style: { fontSize: '0.75rem', color: '#64748b' } },
1329
+ "Use ",
1330
+ React.createElement("strong", null, "One-Click Auth"),
1331
+ " for instant access.")),
1332
+ React.createElement("div", { style: { display: 'flex', gap: '12px', marginTop: '10px' } },
2375
1333
  React.createElement("button", { onClick: cancel, style: {
2376
- display: 'block',
2377
- width: '100%',
1334
+ flex: 2,
2378
1335
  padding: '16px',
2379
1336
  backgroundColor: 'transparent',
2380
1337
  color: '#64748b',
@@ -2384,13 +1341,71 @@ const QidSignInButton = ({ sdk, onSuccess, onError, className, buttonText = 'Log
2384
1341
  fontWeight: '700',
2385
1342
  transition: 'all 0.2s',
2386
1343
  fontSize: '0.9rem'
2387
- } }, "Cancel Handshake")),
1344
+ } }, "Cancel"),
1345
+ React.createElement("button", { onClick: () => {
1346
+ setAppError(false);
1347
+ const deepLink = `qidcloud://authorize?sessionId=${session.sessionId}`; // Corrected format per docs
1348
+ // Timeout to check if app opened
1349
+ const start = Date.now();
1350
+ window.location.href = deepLink;
1351
+ setTimeout(() => {
1352
+ if (Date.now() - start < 1500) {
1353
+ setAppError(true);
1354
+ }
1355
+ }, 1000);
1356
+ }, style: {
1357
+ flex: 1,
1358
+ padding: '16px',
1359
+ backgroundColor: 'rgba(0, 229, 255, 0.1)',
1360
+ color: '#00e5ff',
1361
+ border: '1px solid rgba(0, 229, 255, 0.3)',
1362
+ borderRadius: '16px',
1363
+ cursor: 'pointer',
1364
+ display: 'flex',
1365
+ alignItems: 'center',
1366
+ justifyContent: 'center',
1367
+ transition: 'all 0.2s'
1368
+ }, title: "Authenticate with QidCloud App" },
1369
+ React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" },
1370
+ React.createElement("rect", { x: "5", y: "2", width: "14", height: "20", rx: "2", ry: "2" }),
1371
+ React.createElement("line", { x1: "12", y1: "18", x2: "12.01", y2: "18" })))),
1372
+ appError && (React.createElement("p", { style: { color: '#f59e0b', fontSize: '0.75rem', marginTop: '12px', fontWeight: '600' } }, "QidCloud App not found on device")),
2388
1373
  React.createElement("div", { style: { marginTop: '25px', fontSize: '0.75rem', color: '#475569' } },
2389
1374
  "Session ID: ",
2390
1375
  session.sessionId.slice(0, 8),
2391
1376
  "..."))))));
2392
1377
  };
2393
1378
 
1379
+ /**
1380
+ * A comprehensive login component for QidCloud.
1381
+ * STRICT SECURITY: ONLY supports QR Scanning (Mobile App) for Post-Quantum security.
1382
+ * Conventional login is not available in the SDK to prevent password transmission in third-party apps.
1383
+ */
1384
+ const QidCloudLogin = ({ sdk, onSuccess, onError, className }) => {
1385
+ return (React.createElement("div", { className: `qid-login-container ${className || ''}`, style: {
1386
+ fontFamily: "'Inter', sans-serif",
1387
+ maxWidth: '380px',
1388
+ margin: '0 auto',
1389
+ padding: '30px',
1390
+ backgroundColor: '#050505',
1391
+ borderRadius: '24px',
1392
+ border: '1px solid #333',
1393
+ boxShadow: '0 20px 80px rgba(0,0,0,0.8)',
1394
+ color: '#fff',
1395
+ textAlign: 'center'
1396
+ } },
1397
+ React.createElement("div", { style: { marginBottom: '30px' } },
1398
+ React.createElement("h2", { style: { fontSize: '1.5rem', fontWeight: 700, margin: '0 0 10px 0', letterSpacing: '-0.02em' } }, "QidCloud Login"),
1399
+ React.createElement("p", { style: { color: '#888', fontSize: '0.9rem', margin: 0 } }, "Secure Post-Quantum Access")),
1400
+ React.createElement("div", { style: { marginBottom: '20px', padding: '10px', backgroundColor: '#111', borderRadius: '16px', border: '1px dashed #333' } },
1401
+ React.createElement("p", { style: { fontSize: '0.85rem', color: '#888', marginBottom: '20px', lineHeight: '1.5' } },
1402
+ "Login instantly by scanning the secure QR code with your ",
1403
+ React.createElement("strong", null, "QidCloud App"),
1404
+ "."),
1405
+ React.createElement(QidSignInButton, { sdk: sdk, onSuccess: onSuccess, onError: onError, buttonText: "Login with QIDCLOUD", className: "qid-qr-btn-full" })),
1406
+ React.createElement("p", { style: { fontSize: '0.75rem', color: '#444', marginTop: '20px' } }, "Credentials are never entered on this device.")));
1407
+ };
1408
+
2394
1409
  class QidCloud {
2395
1410
  config;
2396
1411
  api;
@@ -2399,6 +1414,10 @@ class QidCloud {
2399
1414
  edge;
2400
1415
  vault;
2401
1416
  logs;
1417
+ projects;
1418
+ resources;
1419
+ sdk;
1420
+ billing;
2402
1421
  constructor(config) {
2403
1422
  this.config = {
2404
1423
  baseUrl: 'https://api.qidcloud.com',
@@ -2416,6 +1435,10 @@ class QidCloud {
2416
1435
  this.edge = new EdgeModule(this);
2417
1436
  this.vault = new VaultModule(this);
2418
1437
  this.logs = new LogsModule(this);
1438
+ this.projects = new ProjectModule(this);
1439
+ this.resources = new ResourceModule(this);
1440
+ this.sdk = new SdkModule(this);
1441
+ this.billing = new BillingModule(this);
2419
1442
  }
2420
1443
  /**
2421
1444
  * Get the current project configuration
@@ -2426,6 +1449,7 @@ class QidCloud {
2426
1449
  }
2427
1450
 
2428
1451
  exports.QidCloud = QidCloud;
1452
+ exports.QidCloudLogin = QidCloudLogin;
2429
1453
  exports.QidSignInButton = QidSignInButton;
2430
1454
  exports.default = QidCloud;
2431
1455
  exports.useQidAuth = useQidAuth;