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