@athena-tracker/tracker 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,2860 +1,175 @@
1
- import { StyleSheet, View, ActivityIndicator, Text, AppState, PanResponder } from 'react-native';
2
-
3
- /**
4
- * Auto-Detection Logic
5
- *
6
- * Automatically detects whether to use on-device or server-side inference
7
- * based on availability of onnxruntime-react-native
8
- */
9
- async function detectInferenceMode(configMode) {
10
- // Respect explicit configuration
11
- if (configMode === 'on-device') {
12
- console.log('[ATHENA] Forcing on-device inference mode');
13
- return 'on-device';
14
- }
15
- if (configMode === 'server') {
16
- console.log('[ATHENA] Forcing server-side inference mode');
17
- return 'server';
18
- }
19
- // Auto-detect based on onnxruntime-react-native availability
20
- try {
21
- // Try to dynamically import onnxruntime-react-native
22
- await import('onnxruntime-react-native');
23
- console.log('[ATHENA] On-device inference available (onnxruntime-react-native detected)');
24
- return 'on-device';
25
- } catch (error) {
26
- console.log('[ATHENA] Falling back to server-side inference (onnxruntime-react-native not found)');
27
- return 'server';
28
- }
29
- }
30
- /**
31
- * Check if running in React Native environment
32
- */
33
- function isReactNative() {
34
- return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
35
- }
36
- /**
37
- * Check if running in browser environment
38
- */
39
- function isBrowser() {
40
- return typeof window !== 'undefined' && typeof document !== 'undefined';
41
- }
42
1
  /**
43
- * Get platform identifier
2
+ * @athena-tracker/tracker
3
+ * ATHENA Analytics tracker SDK wrapper
44
4
  */
45
- function getPlatform() {
46
- if (isReactNative()) {
47
- return 'react-native';
48
- } else if (isBrowser()) {
49
- return 'web';
50
- }
51
- return 'unknown';
52
- }
53
-
54
- /**
55
- * On-Device Inference Module
56
- *
57
- * Uses onnxruntime-react-native for local ML inference
58
- * Target latency: <10ms P95
59
- */
60
- let InferenceSession;
61
- let Tensor;
62
- // Dynamically import ONNX Runtime (only available in React Native)
63
- async function loadOnnxRuntime() {
64
- try {
65
- const onnx = await import('onnxruntime-react-native');
66
- InferenceSession = onnx.InferenceSession;
67
- Tensor = onnx.Tensor;
68
- return true;
69
- } catch (error) {
70
- console.error('[ATHENA] Failed to load onnxruntime-react-native:', error);
71
- return false;
72
- }
73
- }
74
- class OnDeviceInference {
75
- constructor() {
76
- this.session = null;
77
- this.modelLoaded = false;
78
- }
79
- /**
80
- * Initialize ONNX session with model file
81
- */
82
- async initialize(modelPath) {
83
- console.log('[ATHENA] Loading ONNX model for on-device inference...');
84
- // Load ONNX Runtime
85
- const loaded = await loadOnnxRuntime();
86
- if (!loaded) {
87
- throw new Error('onnxruntime-react-native not available');
88
- }
89
- try {
90
- const startTime = performance.now();
91
- this.session = await InferenceSession.create(modelPath);
92
- const loadTime = performance.now() - startTime;
93
- this.modelLoaded = true;
94
- console.log(`[ATHENA] ONNX model loaded successfully (${loadTime.toFixed(0)}ms)`);
95
- } catch (error) {
96
- console.error('[ATHENA] Failed to load ONNX model:', error);
97
- throw new Error(`Model loading failed: ${error}`);
98
- }
99
- }
100
- /**
101
- * Run inference on feature vector
102
- */
103
- async predict(features) {
104
- if (!this.modelLoaded || !this.session) {
105
- throw new Error('ONNX model not initialized. Call initialize() first.');
106
- }
107
- const startTime = performance.now();
108
- try {
109
- // Create input tensor
110
- const inputTensor = new Tensor('float32', features, [1, features.length]);
111
- const feeds = {
112
- input: inputTensor
113
- };
114
- // Run inference
115
- const results = await this.session.run(feeds);
116
- const inferenceTime = performance.now() - startTime;
117
- // Parse output
118
- const prediction = this.parseOutput(results.output);
119
- console.log(`[ATHENA] On-device inference complete: ${inferenceTime.toFixed(2)}ms ` + `(class: ${prediction.predicted_class}, confidence: ${prediction.confidence.toFixed(2)})`);
120
- return {
121
- ...prediction,
122
- inference_time_ms: Math.round(inferenceTime * 100) / 100,
123
- inference_location: 'on-device',
124
- timestamp: new Date().toISOString()
125
- };
126
- } catch (error) {
127
- console.error('[ATHENA] On-device inference failed:', error);
128
- throw new Error(`Inference failed: ${error}`);
129
- }
130
- }
131
- /**
132
- * Parse ONNX output tensor to prediction result
133
- */
134
- parseOutput(outputTensor) {
135
- const data = outputTensor.data;
136
- // Extract predictions from model output
137
- // Model outputs: [predicted_class_idx, confidence, purchase_intent, cart_abandon_risk, checkout_abandon_risk]
138
- const predictedClassIdx = data[0];
139
- const confidence = data[1];
140
- const purchaseIntent = data[2];
141
- const cartAbandonRisk = data[3] || 0;
142
- const checkoutAbandonRisk = data[4] || 0;
143
- // Map class index to label
144
- const classLabels = ['engaged_explorer', 'high_intent_buyer', 'cart_abandoner', 'checkout_abandoner', 'bounce_risk'];
145
- const predictedClass = classLabels[predictedClassIdx] || 'unknown';
146
- // Determine archetype based on purchase intent
147
- let archetype;
148
- if (purchaseIntent >= 0.85) {
149
- archetype = 'fast_mover';
150
- } else if (purchaseIntent >= 0.60) {
151
- archetype = 'on_track';
152
- } else if (purchaseIntent >= 0.40) {
153
- archetype = 'slow_adopter';
154
- } else if (purchaseIntent >= 0.20) {
155
- archetype = 'at_risk';
156
- } else {
157
- archetype = 'different_path';
5
+ class AthenaTrackerSDK {
6
+ constructor(config) {
7
+ this.scriptLoaded = false;
8
+ this.loadPromise = null;
9
+ this.config = {
10
+ apiUrl: 'https://tracker.pascal.cx',
11
+ sampleRate: 1.0,
12
+ ...config,
13
+ };
14
+ }
15
+ /**
16
+ * Load the ATHENA tracker script dynamically
17
+ */
18
+ async load() {
19
+ if (this.scriptLoaded)
20
+ return;
21
+ if (this.loadPromise)
22
+ return this.loadPromise;
23
+ this.loadPromise = new Promise((resolve, reject) => {
24
+ const script = document.createElement('script');
25
+ script.src = `${this.config.apiUrl}/v1/tracker.min.js`;
26
+ script.async = true;
27
+ script.onload = () => {
28
+ this.scriptLoaded = true;
29
+ this.initialize();
30
+ resolve();
31
+ };
32
+ script.onerror = () => {
33
+ reject(new Error('Failed to load ATHENA tracker script'));
34
+ };
35
+ document.head.appendChild(script);
36
+ });
37
+ return this.loadPromise;
38
+ }
39
+ /**
40
+ * Initialize the tracker with configuration
41
+ */
42
+ initialize() {
43
+ if (typeof window !== 'undefined' && window.PascalTracker) {
44
+ window.athenaTracker = new window.PascalTracker(this.config);
45
+ }
158
46
  }
159
- // Generate recommendations
160
- const recommendation = this.generateRecommendation(predictedClass, purchaseIntent, cartAbandonRisk, checkoutAbandonRisk);
161
- return {
162
- predicted_class: predictedClass,
163
- confidence,
164
- archetype,
165
- purchase_intent: purchaseIntent,
166
- cart_abandonment_risk: cartAbandonRisk,
167
- checkout_abandonment_risk: checkoutAbandonRisk,
168
- ...recommendation
169
- };
170
- }
171
- /**
172
- * Generate action recommendations based on prediction
173
- */
174
- generateRecommendation(predictedClass, purchaseIntent, cartAbandonRisk, checkoutAbandonRisk) {
175
- // High cart abandonment risk
176
- if (cartAbandonRisk > 0.7) {
177
- return {
178
- recommended_action: 'Show cart abandonment discount (10-15% off)',
179
- urgency: 'high',
180
- trigger_reason: `High cart abandonment risk (${(cartAbandonRisk * 100).toFixed(0)}%)`
181
- };
47
+ /**
48
+ * Get the underlying tracker instance
49
+ */
50
+ getTracker() {
51
+ if (typeof window === 'undefined') {
52
+ console.warn('ATHENA Tracker: window is not defined (SSR environment)');
53
+ return null;
54
+ }
55
+ if (!window.athenaTracker) {
56
+ console.warn('ATHENA Tracker: not initialized. Call load() first.');
57
+ return null;
58
+ }
59
+ return window.athenaTracker;
60
+ }
61
+ /**
62
+ * Identify a user
63
+ */
64
+ identify(userId, properties) {
65
+ const tracker = this.getTracker();
66
+ if (tracker && tracker.identify) {
67
+ tracker.identify({
68
+ userId,
69
+ ...properties,
70
+ });
71
+ }
182
72
  }
183
- // High checkout abandonment risk
184
- if (checkoutAbandonRisk > 0.7) {
185
- return {
186
- recommended_action: 'Simplify checkout flow or offer free shipping',
187
- urgency: 'critical',
188
- trigger_reason: `High checkout abandonment risk (${(checkoutAbandonRisk * 100).toFixed(0)}%)`
189
- };
73
+ /**
74
+ * Track a custom event
75
+ */
76
+ track(eventName, properties) {
77
+ const tracker = this.getTracker();
78
+ if (tracker && tracker.track) {
79
+ tracker.track(eventName, properties);
80
+ }
190
81
  }
191
- // High purchase intent
192
- if (purchaseIntent > 0.8) {
193
- return {
194
- recommended_action: 'Show product recommendations or upsell',
195
- urgency: 'medium',
196
- trigger_reason: `High purchase intent (${(purchaseIntent * 100).toFixed(0)}%)`
197
- };
82
+ /**
83
+ * Track a page view
84
+ */
85
+ page(pageName, properties) {
86
+ const tracker = this.getTracker();
87
+ if (tracker && tracker.page) {
88
+ tracker.page(pageName, properties);
89
+ }
198
90
  }
199
- // Low purchase intent
200
- if (purchaseIntent < 0.3) {
201
- return {
202
- recommended_action: 'Show value proposition or testimonials',
203
- urgency: 'low',
204
- trigger_reason: `Low purchase intent (${(purchaseIntent * 100).toFixed(0)}%)`
205
- };
91
+ /**
92
+ * Reset user identity (logout)
93
+ */
94
+ reset() {
95
+ const tracker = this.getTracker();
96
+ if (tracker && tracker.reset) {
97
+ tracker.reset();
98
+ }
206
99
  }
207
- return {
208
- recommended_action: 'Continue monitoring',
209
- urgency: 'low'
210
- };
211
- }
212
- /**
213
- * Check if model is loaded
214
- */
215
- isReady() {
216
- return this.modelLoaded;
217
- }
218
- /**
219
- * Cleanup resources
220
- */
221
- async dispose() {
222
- if (this.session) {
223
- try {
224
- // ONNX Runtime sessions should be disposed
225
- await this.session.release?.();
226
- console.log('[ATHENA] On-device inference session disposed');
227
- } catch (error) {
228
- console.warn('[ATHENA] Failed to dispose session:', error);
229
- }
230
- this.session = null;
231
- this.modelLoaded = false;
100
+ /**
101
+ * Get current session ID
102
+ */
103
+ getSessionId() {
104
+ const tracker = this.getTracker();
105
+ if (tracker && tracker.getSessionId) {
106
+ return tracker.getSessionId();
107
+ }
108
+ return null;
109
+ }
110
+ /**
111
+ * Get current user ID
112
+ */
113
+ getUserId() {
114
+ const tracker = this.getTracker();
115
+ if (tracker && tracker.getUserId) {
116
+ return tracker.getUserId();
117
+ }
118
+ return null;
232
119
  }
233
- }
234
120
  }
235
-
121
+ // Singleton instance
122
+ let trackerInstance = null;
236
123
  /**
237
- * Server-Side Inference Module
238
- *
239
- * Fallback inference via HTTP API when on-device inference is not available
240
- * Target latency: <100ms P95
124
+ * Initialize ATHENA tracker
241
125
  */
242
- class ServerInference {
243
- constructor(apiUrl, appToken, timeout = 5000) {
244
- this.apiUrl = apiUrl;
245
- this.appToken = appToken;
246
- this.timeout = timeout;
247
- }
248
- /**
249
- * Make prediction request to server
250
- */
251
- async predict(events, sessionId, userId) {
252
- const startTime = Date.now();
253
- try {
254
- const requestBody = {
255
- app_token: this.appToken,
256
- events,
257
- session_id: sessionId,
258
- user_id: userId
259
- };
260
- console.log(`[ATHENA] Sending ${events.length} events to server for inference...`);
261
- const response = await this.fetchWithTimeout(`${this.apiUrl}/v1/predict`, {
262
- method: 'POST',
263
- headers: {
264
- 'Content-Type': 'application/json',
265
- 'X-App-Token': this.appToken
266
- },
267
- body: JSON.stringify(requestBody)
268
- }, this.timeout);
269
- if (!response.ok) {
270
- const errorText = await response.text();
271
- throw new Error(`Server inference failed: ${response.status} ${errorText}`);
272
- }
273
- const result = await response.json();
274
- const latency = Date.now() - startTime;
275
- console.log(`[ATHENA] Server-side inference complete: ${latency}ms ` + `(class: ${result.predicted_class}, confidence: ${result.confidence.toFixed(2)})`);
276
- return {
277
- ...result,
278
- inference_time_ms: latency,
279
- inference_location: 'server',
280
- timestamp: result.timestamp || new Date().toISOString()
281
- };
282
- } catch (error) {
283
- const latency = Date.now() - startTime;
284
- console.error(`[ATHENA] Server inference failed after ${latency}ms:`, error.message);
285
- throw new Error(`Server inference failed: ${error.message}`);
286
- }
287
- }
288
- /**
289
- * Fetch with timeout
290
- */
291
- async fetchWithTimeout(url, options, timeout) {
292
- const controller = new AbortController();
293
- const timeoutId = setTimeout(() => controller.abort(), timeout);
294
- try {
295
- const response = await fetch(url, {
296
- ...options,
297
- signal: controller.signal
298
- });
299
- clearTimeout(timeoutId);
300
- return response;
301
- } catch (error) {
302
- clearTimeout(timeoutId);
303
- if (error.name === 'AbortError') {
304
- throw new Error(`Request timeout after ${timeout}ms`);
305
- }
306
- throw error;
307
- }
308
- }
309
- /**
310
- * Test server connectivity
311
- */
312
- async testConnection() {
313
- try {
314
- const response = await this.fetchWithTimeout(`${this.apiUrl}/health`, {
315
- method: 'GET'
316
- }, 3000);
317
- return response.ok;
318
- } catch (error) {
319
- console.warn('[ATHENA] Server connectivity test failed:', error);
320
- return false;
126
+ function initTracker(config) {
127
+ if (!trackerInstance) {
128
+ trackerInstance = new AthenaTrackerSDK(config);
321
129
  }
322
- }
323
- /**
324
- * Update configuration
325
- */
326
- updateConfig(apiUrl, appToken, timeout) {
327
- if (apiUrl) this.apiUrl = apiUrl;
328
- if (appToken) this.appToken = appToken;
329
- if (timeout) this.timeout = timeout;
330
- }
130
+ return trackerInstance;
331
131
  }
332
-
333
132
  /**
334
- * ATHENA Tracker - Main Class
335
- *
336
- * Unified interface for behavioral tracking with dual-mode ML inference
133
+ * Get the tracker instance
337
134
  */
338
- const DEFAULT_API_URL = 'https://tracker.pascal.cx';
339
- const DEFAULT_MODEL_PATH = 'https://tracker.pascal.cx/models/base_model_int8.onnx';
340
- const DEFAULT_BATCH_SIZE = 10;
341
- const DEFAULT_BATCH_INTERVAL_MS = 10000; // 10 seconds
342
- class AthenaTracker {
343
- constructor() {
344
- this.config = null;
345
- this.state = {
346
- initialized: false,
347
- inferenceMode: null,
348
- sessionId: null,
349
- userId: null,
350
- events: []
351
- };
352
- this.onDeviceInference = null;
353
- this.serverInference = null;
354
- this.batchIntervalId = null;
355
- // Private constructor for singleton
356
- }
357
- /**
358
- * Get singleton instance
359
- */
360
- static getInstance() {
361
- if (!AthenaTracker.instance) {
362
- AthenaTracker.instance = new AthenaTracker();
363
- }
364
- return AthenaTracker.instance;
365
- }
366
- /**
367
- * Initialize tracker
368
- */
369
- static async init(config) {
370
- const instance = AthenaTracker.getInstance();
371
- if (instance.state.initialized) {
372
- console.warn('[ATHENA] Already initialized');
373
- return;
135
+ function getTracker() {
136
+ if (!trackerInstance) {
137
+ console.warn('ATHENA Tracker: not initialized. Call initTracker() first.');
374
138
  }
375
- console.log('[ATHENA] Initializing tracker...');
376
- instance.config = {
377
- ...config,
378
- apiUrl: config.apiUrl || DEFAULT_API_URL,
379
- modelPath: config.modelPath || DEFAULT_MODEL_PATH,
380
- serverInferenceUrl: config.serverInferenceUrl || `${config.apiUrl || DEFAULT_API_URL}/v1/predict`,
381
- batching: {
382
- size: config.batching?.size || DEFAULT_BATCH_SIZE,
383
- intervalMs: config.batching?.intervalMs || DEFAULT_BATCH_INTERVAL_MS
384
- }
385
- };
386
- // Detect inference mode
387
- const detectedMode = await detectInferenceMode(config.inferenceMode);
388
- instance.state.inferenceMode = detectedMode;
389
- // Initialize appropriate inference engine
390
- if (detectedMode === 'on-device') {
391
- await instance.initializeOnDevice();
392
- } else {
393
- await instance.initializeServer();
394
- }
395
- // Generate session ID
396
- instance.state.sessionId = instance.generateSessionId();
397
- // Start event batching
398
- instance.startBatching();
399
- instance.state.initialized = true;
400
- console.log(`[ATHENA] Tracker initialized successfully (mode: ${detectedMode}, platform: ${getPlatform()})`);
401
- }
402
- /**
403
- * Initialize on-device inference
404
- */
405
- async initializeOnDevice() {
406
- try {
407
- this.onDeviceInference = new OnDeviceInference();
408
- await this.onDeviceInference.initialize(this.config.modelPath);
409
- console.log('[ATHENA] On-device inference ready');
410
- } catch (error) {
411
- console.error('[ATHENA] On-device inference initialization failed:', error);
412
- console.log('[ATHENA] Falling back to server-side inference');
413
- this.state.inferenceMode = 'server';
414
- await this.initializeServer();
415
- }
416
- }
417
- /**
418
- * Initialize server-side inference
419
- */
420
- async initializeServer() {
421
- this.serverInference = new ServerInference(this.config.serverInferenceUrl, this.config.appToken);
422
- // Test connectivity
423
- const connected = await this.serverInference.testConnection();
424
- if (!connected) {
425
- console.warn('[ATHENA] Server connectivity test failed - predictions may fail');
426
- } else {
427
- console.log('[ATHENA] Server-side inference ready');
428
- }
429
- }
430
- /**
431
- * Identify a user
432
- */
433
- static identify(userId, traits) {
434
- const instance = AthenaTracker.getInstance();
435
- instance.state.userId = userId;
436
- instance.track('identify', {
437
- user_id: userId,
438
- ...traits
439
- });
440
- console.log(`[ATHENA] User identified: ${userId}`);
441
- }
442
- /**
443
- * Track an event
444
- */
445
- static track(eventType, properties) {
446
- const instance = AthenaTracker.getInstance();
447
- if (!instance.state.initialized) {
448
- console.warn('[ATHENA] Tracker not initialized. Call init() first.');
449
- return;
450
- }
451
- const event = {
452
- event_type: eventType,
453
- timestamp: Date.now(),
454
- properties: properties || {},
455
- session_id: instance.state.sessionId || undefined,
456
- user_id: instance.state.userId || undefined
457
- };
458
- instance.state.events.push(event);
459
- if (instance.config?.debug) {
460
- console.log('[ATHENA] Event tracked:', event);
461
- }
462
- // Trigger immediate inference if batch size reached
463
- if (instance.state.events.length >= instance.config.batching.size) {
464
- instance.processBatch();
465
- }
466
- }
467
- /**
468
- * Process event batch and run inference
469
- */
470
- async processBatch() {
471
- if (this.state.events.length === 0) return;
472
- const events = [...this.state.events];
473
- this.state.events = [];
474
- try {
475
- const prediction = await this.runInference(events);
476
- if (this.config?.webhook?.enabled && this.config.webhook.url) {
477
- await this.sendWebhook(prediction);
478
- }
479
- if (this.config?.debug) {
480
- console.log('[ATHENA] Prediction:', prediction);
481
- }
482
- } catch (error) {
483
- console.error('[ATHENA] Failed to process batch:', error);
484
- // Re-queue events on failure
485
- this.state.events.unshift(...events);
486
- }
487
- }
488
- /**
489
- * Run inference (delegates to on-device or server)
490
- */
491
- async runInference(events) {
492
- if (this.state.inferenceMode === 'on-device' && this.onDeviceInference) {
493
- // Extract features from events (simplified - would need proper feature extraction)
494
- const features = this.extractFeatures(events);
495
- return await this.onDeviceInference.predict(features);
496
- } else if (this.state.inferenceMode === 'server' && this.serverInference) {
497
- return await this.serverInference.predict(events, this.state.sessionId || undefined, this.state.userId || undefined);
498
- } else {
499
- throw new Error('No inference engine available');
500
- }
501
- }
502
- /**
503
- * Extract features from events (placeholder)
504
- * In production, this would use proper feature engineering
505
- */
506
- extractFeatures(events) {
507
- // Simplified feature extraction - 20 features
508
- const features = new Float32Array(20);
509
- // Event count
510
- features[0] = events.length;
511
- // Unique event types
512
- const uniqueTypes = new Set(events.map(e => e.event_type));
513
- features[1] = uniqueTypes.size;
514
- // Time span
515
- if (events.length > 1) {
516
- const timeSpan = events[events.length - 1].timestamp - events[0].timestamp;
517
- features[2] = timeSpan / 1000; // seconds
518
- }
519
- // Fill remaining features with event type frequencies
520
- const typeCounts = new Map();
521
- events.forEach(e => {
522
- typeCounts.set(e.event_type, (typeCounts.get(e.event_type) || 0) + 1);
523
- });
524
- let idx = 3;
525
- ['click', 'scroll', 'page_view', 'cart_add', 'checkout_start'].forEach(type => {
526
- features[idx++] = typeCounts.get(type) || 0;
527
- });
528
- return features;
529
- }
530
- /**
531
- * Send prediction to webhook
532
- */
533
- async sendWebhook(prediction) {
534
- if (!this.config?.webhook?.url) return;
535
- const maxAttempts = this.config.webhook.retry?.maxAttempts || 3;
536
- const backoffMs = this.config.webhook.retry?.backoffMs || 1000;
537
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
538
- try {
539
- const response = await fetch(this.config.webhook.url, {
540
- method: 'POST',
541
- headers: {
542
- 'Content-Type': 'application/json',
543
- 'X-App-Token': this.config.appToken
544
- },
545
- body: JSON.stringify({
546
- ...prediction,
547
- session_id: this.state.sessionId,
548
- user_id: this.state.userId
549
- })
550
- });
551
- if (response.ok) {
552
- if (this.config.debug) {
553
- console.log('[ATHENA] Webhook delivered successfully');
554
- }
555
- return;
556
- }
557
- throw new Error(`Webhook failed: ${response.status}`);
558
- } catch (error) {
559
- console.warn(`[ATHENA] Webhook attempt ${attempt}/${maxAttempts} failed:`, error);
560
- if (attempt < maxAttempts) {
561
- await this.sleep(backoffMs * Math.pow(2, attempt - 1));
562
- }
563
- }
564
- }
565
- console.error('[ATHENA] Webhook delivery failed after all retries');
566
- }
567
- /**
568
- * Start event batching interval
569
- */
570
- startBatching() {
571
- this.batchIntervalId = setInterval(() => {
572
- this.processBatch();
573
- }, this.config.batching.intervalMs);
574
- }
575
- /**
576
- * Get inference mode
577
- */
578
- static getInferenceMode() {
579
- return AthenaTracker.getInstance().state.inferenceMode;
580
- }
581
- /**
582
- * Get session ID
583
- */
584
- static getSessionId() {
585
- return AthenaTracker.getInstance().state.sessionId;
586
- }
587
- /**
588
- * Cleanup resources
589
- */
590
- static async dispose() {
591
- const instance = AthenaTracker.getInstance();
592
- if (instance.batchIntervalId) {
593
- clearInterval(instance.batchIntervalId);
594
- }
595
- if (instance.onDeviceInference) {
596
- await instance.onDeviceInference.dispose();
597
- }
598
- instance.state.initialized = false;
599
- console.log('[ATHENA] Tracker disposed');
600
- }
601
- /**
602
- * Generate session ID
603
- */
604
- generateSessionId() {
605
- return `sess_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
606
- }
607
- /**
608
- * Sleep utility
609
- */
610
- sleep(ms) {
611
- return new Promise(resolve => setTimeout(resolve, ms));
612
- }
613
- }
614
- AthenaTracker.instance = null;
615
-
616
- function getDefaultExportFromCjs (x) {
617
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
139
+ return trackerInstance;
618
140
  }
619
-
620
- var react = {exports: {}};
621
-
622
- var react_production = {};
623
-
624
141
  /**
625
- * @license React
626
- * react.production.js
627
- *
628
- * Copyright (c) Meta Platforms, Inc. and affiliates.
629
- *
630
- * This source code is licensed under the MIT license found in the
631
- * LICENSE file in the root directory of this source tree.
142
+ * Convenience methods (use singleton instance)
632
143
  */
633
-
634
- var hasRequiredReact_production;
635
-
636
- function requireReact_production () {
637
- if (hasRequiredReact_production) return react_production;
638
- hasRequiredReact_production = 1;
639
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
640
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
641
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
642
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
643
- REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
644
- REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
645
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
646
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
647
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
648
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
649
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
650
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
651
- MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
652
- function getIteratorFn(maybeIterable) {
653
- if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
654
- maybeIterable =
655
- (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
656
- maybeIterable["@@iterator"];
657
- return "function" === typeof maybeIterable ? maybeIterable : null;
658
- }
659
- var ReactNoopUpdateQueue = {
660
- isMounted: function () {
661
- return false;
662
- },
663
- enqueueForceUpdate: function () {},
664
- enqueueReplaceState: function () {},
665
- enqueueSetState: function () {}
666
- },
667
- assign = Object.assign,
668
- emptyObject = {};
669
- function Component(props, context, updater) {
670
- this.props = props;
671
- this.context = context;
672
- this.refs = emptyObject;
673
- this.updater = updater || ReactNoopUpdateQueue;
674
- }
675
- Component.prototype.isReactComponent = {};
676
- Component.prototype.setState = function (partialState, callback) {
677
- if (
678
- "object" !== typeof partialState &&
679
- "function" !== typeof partialState &&
680
- null != partialState
681
- )
682
- throw Error(
683
- "takes an object of state variables to update or a function which returns an object of state variables."
684
- );
685
- this.updater.enqueueSetState(this, partialState, callback, "setState");
686
- };
687
- Component.prototype.forceUpdate = function (callback) {
688
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
689
- };
690
- function ComponentDummy() {}
691
- ComponentDummy.prototype = Component.prototype;
692
- function PureComponent(props, context, updater) {
693
- this.props = props;
694
- this.context = context;
695
- this.refs = emptyObject;
696
- this.updater = updater || ReactNoopUpdateQueue;
697
- }
698
- var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
699
- pureComponentPrototype.constructor = PureComponent;
700
- assign(pureComponentPrototype, Component.prototype);
701
- pureComponentPrototype.isPureReactComponent = true;
702
- var isArrayImpl = Array.isArray;
703
- function noop() {}
704
- var ReactSharedInternals = { H: null, A: null, T: null, S: null },
705
- hasOwnProperty = Object.prototype.hasOwnProperty;
706
- function ReactElement(type, key, props) {
707
- var refProp = props.ref;
708
- return {
709
- $$typeof: REACT_ELEMENT_TYPE,
710
- type: type,
711
- key: key,
712
- ref: void 0 !== refProp ? refProp : null,
713
- props: props
714
- };
715
- }
716
- function cloneAndReplaceKey(oldElement, newKey) {
717
- return ReactElement(oldElement.type, newKey, oldElement.props);
718
- }
719
- function isValidElement(object) {
720
- return (
721
- "object" === typeof object &&
722
- null !== object &&
723
- object.$$typeof === REACT_ELEMENT_TYPE
724
- );
725
- }
726
- function escape(key) {
727
- var escaperLookup = { "=": "=0", ":": "=2" };
728
- return (
729
- "$" +
730
- key.replace(/[=:]/g, function (match) {
731
- return escaperLookup[match];
732
- })
733
- );
734
- }
735
- var userProvidedKeyEscapeRegex = /\/+/g;
736
- function getElementKey(element, index) {
737
- return "object" === typeof element && null !== element && null != element.key
738
- ? escape("" + element.key)
739
- : index.toString(36);
740
- }
741
- function resolveThenable(thenable) {
742
- switch (thenable.status) {
743
- case "fulfilled":
744
- return thenable.value;
745
- case "rejected":
746
- throw thenable.reason;
747
- default:
748
- switch (
749
- ("string" === typeof thenable.status
750
- ? thenable.then(noop, noop)
751
- : ((thenable.status = "pending"),
752
- thenable.then(
753
- function (fulfilledValue) {
754
- "pending" === thenable.status &&
755
- ((thenable.status = "fulfilled"),
756
- (thenable.value = fulfilledValue));
757
- },
758
- function (error) {
759
- "pending" === thenable.status &&
760
- ((thenable.status = "rejected"), (thenable.reason = error));
761
- }
762
- )),
763
- thenable.status)
764
- ) {
765
- case "fulfilled":
766
- return thenable.value;
767
- case "rejected":
768
- throw thenable.reason;
769
- }
770
- }
771
- throw thenable;
772
- }
773
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
774
- var type = typeof children;
775
- if ("undefined" === type || "boolean" === type) children = null;
776
- var invokeCallback = false;
777
- if (null === children) invokeCallback = true;
778
- else
779
- switch (type) {
780
- case "bigint":
781
- case "string":
782
- case "number":
783
- invokeCallback = true;
784
- break;
785
- case "object":
786
- switch (children.$$typeof) {
787
- case REACT_ELEMENT_TYPE:
788
- case REACT_PORTAL_TYPE:
789
- invokeCallback = true;
790
- break;
791
- case REACT_LAZY_TYPE:
792
- return (
793
- (invokeCallback = children._init),
794
- mapIntoArray(
795
- invokeCallback(children._payload),
796
- array,
797
- escapedPrefix,
798
- nameSoFar,
799
- callback
800
- )
801
- );
802
- }
803
- }
804
- if (invokeCallback)
805
- return (
806
- (callback = callback(children)),
807
- (invokeCallback =
808
- "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar),
809
- isArrayImpl(callback)
810
- ? ((escapedPrefix = ""),
811
- null != invokeCallback &&
812
- (escapedPrefix =
813
- invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
814
- mapIntoArray(callback, array, escapedPrefix, "", function (c) {
815
- return c;
816
- }))
817
- : null != callback &&
818
- (isValidElement(callback) &&
819
- (callback = cloneAndReplaceKey(
820
- callback,
821
- escapedPrefix +
822
- (null == callback.key ||
823
- (children && children.key === callback.key)
824
- ? ""
825
- : ("" + callback.key).replace(
826
- userProvidedKeyEscapeRegex,
827
- "$&/"
828
- ) + "/") +
829
- invokeCallback
830
- )),
831
- array.push(callback)),
832
- 1
833
- );
834
- invokeCallback = 0;
835
- var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
836
- if (isArrayImpl(children))
837
- for (var i = 0; i < children.length; i++)
838
- (nameSoFar = children[i]),
839
- (type = nextNamePrefix + getElementKey(nameSoFar, i)),
840
- (invokeCallback += mapIntoArray(
841
- nameSoFar,
842
- array,
843
- escapedPrefix,
844
- type,
845
- callback
846
- ));
847
- else if (((i = getIteratorFn(children)), "function" === typeof i))
848
- for (
849
- children = i.call(children), i = 0;
850
- !(nameSoFar = children.next()).done;
851
-
852
- )
853
- (nameSoFar = nameSoFar.value),
854
- (type = nextNamePrefix + getElementKey(nameSoFar, i++)),
855
- (invokeCallback += mapIntoArray(
856
- nameSoFar,
857
- array,
858
- escapedPrefix,
859
- type,
860
- callback
861
- ));
862
- else if ("object" === type) {
863
- if ("function" === typeof children.then)
864
- return mapIntoArray(
865
- resolveThenable(children),
866
- array,
867
- escapedPrefix,
868
- nameSoFar,
869
- callback
870
- );
871
- array = String(children);
872
- throw Error(
873
- "Objects are not valid as a React child (found: " +
874
- ("[object Object]" === array
875
- ? "object with keys {" + Object.keys(children).join(", ") + "}"
876
- : array) +
877
- "). If you meant to render a collection of children, use an array instead."
878
- );
879
- }
880
- return invokeCallback;
881
- }
882
- function mapChildren(children, func, context) {
883
- if (null == children) return children;
884
- var result = [],
885
- count = 0;
886
- mapIntoArray(children, result, "", "", function (child) {
887
- return func.call(context, child, count++);
888
- });
889
- return result;
890
- }
891
- function lazyInitializer(payload) {
892
- if (-1 === payload._status) {
893
- var ctor = payload._result;
894
- ctor = ctor();
895
- ctor.then(
896
- function (moduleObject) {
897
- if (0 === payload._status || -1 === payload._status)
898
- (payload._status = 1), (payload._result = moduleObject);
899
- },
900
- function (error) {
901
- if (0 === payload._status || -1 === payload._status)
902
- (payload._status = 2), (payload._result = error);
903
- }
904
- );
905
- -1 === payload._status && ((payload._status = 0), (payload._result = ctor));
906
- }
907
- if (1 === payload._status) return payload._result.default;
908
- throw payload._result;
909
- }
910
- var reportGlobalError =
911
- "function" === typeof reportError
912
- ? reportError
913
- : function (error) {
914
- if (
915
- "object" === typeof window &&
916
- "function" === typeof window.ErrorEvent
917
- ) {
918
- var event = new window.ErrorEvent("error", {
919
- bubbles: true,
920
- cancelable: true,
921
- message:
922
- "object" === typeof error &&
923
- null !== error &&
924
- "string" === typeof error.message
925
- ? String(error.message)
926
- : String(error),
927
- error: error
928
- });
929
- if (!window.dispatchEvent(event)) return;
930
- } else if (
931
- "object" === typeof process &&
932
- "function" === typeof process.emit
933
- ) {
934
- process.emit("uncaughtException", error);
935
- return;
936
- }
937
- console.error(error);
938
- },
939
- Children = {
940
- map: mapChildren,
941
- forEach: function (children, forEachFunc, forEachContext) {
942
- mapChildren(
943
- children,
944
- function () {
945
- forEachFunc.apply(this, arguments);
946
- },
947
- forEachContext
948
- );
949
- },
950
- count: function (children) {
951
- var n = 0;
952
- mapChildren(children, function () {
953
- n++;
954
- });
955
- return n;
956
- },
957
- toArray: function (children) {
958
- return (
959
- mapChildren(children, function (child) {
960
- return child;
961
- }) || []
962
- );
963
- },
964
- only: function (children) {
965
- if (!isValidElement(children))
966
- throw Error(
967
- "React.Children.only expected to receive a single React element child."
968
- );
969
- return children;
970
- }
971
- };
972
- react_production.Activity = REACT_ACTIVITY_TYPE;
973
- react_production.Children = Children;
974
- react_production.Component = Component;
975
- react_production.Fragment = REACT_FRAGMENT_TYPE;
976
- react_production.Profiler = REACT_PROFILER_TYPE;
977
- react_production.PureComponent = PureComponent;
978
- react_production.StrictMode = REACT_STRICT_MODE_TYPE;
979
- react_production.Suspense = REACT_SUSPENSE_TYPE;
980
- react_production.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
981
- ReactSharedInternals;
982
- react_production.__COMPILER_RUNTIME = {
983
- __proto__: null,
984
- c: function (size) {
985
- return ReactSharedInternals.H.useMemoCache(size);
986
- }
987
- };
988
- react_production.cache = function (fn) {
989
- return function () {
990
- return fn.apply(null, arguments);
991
- };
992
- };
993
- react_production.cacheSignal = function () {
994
- return null;
995
- };
996
- react_production.cloneElement = function (element, config, children) {
997
- if (null === element || void 0 === element)
998
- throw Error(
999
- "The argument must be a React element, but you passed " + element + "."
1000
- );
1001
- var props = assign({}, element.props),
1002
- key = element.key;
1003
- if (null != config)
1004
- for (propName in (void 0 !== config.key && (key = "" + config.key), config))
1005
- !hasOwnProperty.call(config, propName) ||
1006
- "key" === propName ||
1007
- "__self" === propName ||
1008
- "__source" === propName ||
1009
- ("ref" === propName && void 0 === config.ref) ||
1010
- (props[propName] = config[propName]);
1011
- var propName = arguments.length - 2;
1012
- if (1 === propName) props.children = children;
1013
- else if (1 < propName) {
1014
- for (var childArray = Array(propName), i = 0; i < propName; i++)
1015
- childArray[i] = arguments[i + 2];
1016
- props.children = childArray;
1017
- }
1018
- return ReactElement(element.type, key, props);
1019
- };
1020
- react_production.createContext = function (defaultValue) {
1021
- defaultValue = {
1022
- $$typeof: REACT_CONTEXT_TYPE,
1023
- _currentValue: defaultValue,
1024
- _currentValue2: defaultValue,
1025
- _threadCount: 0,
1026
- Provider: null,
1027
- Consumer: null
1028
- };
1029
- defaultValue.Provider = defaultValue;
1030
- defaultValue.Consumer = {
1031
- $$typeof: REACT_CONSUMER_TYPE,
1032
- _context: defaultValue
1033
- };
1034
- return defaultValue;
1035
- };
1036
- react_production.createElement = function (type, config, children) {
1037
- var propName,
1038
- props = {},
1039
- key = null;
1040
- if (null != config)
1041
- for (propName in (void 0 !== config.key && (key = "" + config.key), config))
1042
- hasOwnProperty.call(config, propName) &&
1043
- "key" !== propName &&
1044
- "__self" !== propName &&
1045
- "__source" !== propName &&
1046
- (props[propName] = config[propName]);
1047
- var childrenLength = arguments.length - 2;
1048
- if (1 === childrenLength) props.children = children;
1049
- else if (1 < childrenLength) {
1050
- for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
1051
- childArray[i] = arguments[i + 2];
1052
- props.children = childArray;
1053
- }
1054
- if (type && type.defaultProps)
1055
- for (propName in ((childrenLength = type.defaultProps), childrenLength))
1056
- void 0 === props[propName] &&
1057
- (props[propName] = childrenLength[propName]);
1058
- return ReactElement(type, key, props);
1059
- };
1060
- react_production.createRef = function () {
1061
- return { current: null };
1062
- };
1063
- react_production.forwardRef = function (render) {
1064
- return { $$typeof: REACT_FORWARD_REF_TYPE, render: render };
1065
- };
1066
- react_production.isValidElement = isValidElement;
1067
- react_production.lazy = function (ctor) {
1068
- return {
1069
- $$typeof: REACT_LAZY_TYPE,
1070
- _payload: { _status: -1, _result: ctor },
1071
- _init: lazyInitializer
1072
- };
1073
- };
1074
- react_production.memo = function (type, compare) {
1075
- return {
1076
- $$typeof: REACT_MEMO_TYPE,
1077
- type: type,
1078
- compare: void 0 === compare ? null : compare
1079
- };
1080
- };
1081
- react_production.startTransition = function (scope) {
1082
- var prevTransition = ReactSharedInternals.T,
1083
- currentTransition = {};
1084
- ReactSharedInternals.T = currentTransition;
1085
- try {
1086
- var returnValue = scope(),
1087
- onStartTransitionFinish = ReactSharedInternals.S;
1088
- null !== onStartTransitionFinish &&
1089
- onStartTransitionFinish(currentTransition, returnValue);
1090
- "object" === typeof returnValue &&
1091
- null !== returnValue &&
1092
- "function" === typeof returnValue.then &&
1093
- returnValue.then(noop, reportGlobalError);
1094
- } catch (error) {
1095
- reportGlobalError(error);
1096
- } finally {
1097
- null !== prevTransition &&
1098
- null !== currentTransition.types &&
1099
- (prevTransition.types = currentTransition.types),
1100
- (ReactSharedInternals.T = prevTransition);
1101
- }
1102
- };
1103
- react_production.unstable_useCacheRefresh = function () {
1104
- return ReactSharedInternals.H.useCacheRefresh();
1105
- };
1106
- react_production.use = function (usable) {
1107
- return ReactSharedInternals.H.use(usable);
1108
- };
1109
- react_production.useActionState = function (action, initialState, permalink) {
1110
- return ReactSharedInternals.H.useActionState(action, initialState, permalink);
1111
- };
1112
- react_production.useCallback = function (callback, deps) {
1113
- return ReactSharedInternals.H.useCallback(callback, deps);
1114
- };
1115
- react_production.useContext = function (Context) {
1116
- return ReactSharedInternals.H.useContext(Context);
1117
- };
1118
- react_production.useDebugValue = function () {};
1119
- react_production.useDeferredValue = function (value, initialValue) {
1120
- return ReactSharedInternals.H.useDeferredValue(value, initialValue);
1121
- };
1122
- react_production.useEffect = function (create, deps) {
1123
- return ReactSharedInternals.H.useEffect(create, deps);
1124
- };
1125
- react_production.useEffectEvent = function (callback) {
1126
- return ReactSharedInternals.H.useEffectEvent(callback);
1127
- };
1128
- react_production.useId = function () {
1129
- return ReactSharedInternals.H.useId();
1130
- };
1131
- react_production.useImperativeHandle = function (ref, create, deps) {
1132
- return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
1133
- };
1134
- react_production.useInsertionEffect = function (create, deps) {
1135
- return ReactSharedInternals.H.useInsertionEffect(create, deps);
1136
- };
1137
- react_production.useLayoutEffect = function (create, deps) {
1138
- return ReactSharedInternals.H.useLayoutEffect(create, deps);
1139
- };
1140
- react_production.useMemo = function (create, deps) {
1141
- return ReactSharedInternals.H.useMemo(create, deps);
1142
- };
1143
- react_production.useOptimistic = function (passthrough, reducer) {
1144
- return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
1145
- };
1146
- react_production.useReducer = function (reducer, initialArg, init) {
1147
- return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
1148
- };
1149
- react_production.useRef = function (initialValue) {
1150
- return ReactSharedInternals.H.useRef(initialValue);
1151
- };
1152
- react_production.useState = function (initialState) {
1153
- return ReactSharedInternals.H.useState(initialState);
1154
- };
1155
- react_production.useSyncExternalStore = function (
1156
- subscribe,
1157
- getSnapshot,
1158
- getServerSnapshot
1159
- ) {
1160
- return ReactSharedInternals.H.useSyncExternalStore(
1161
- subscribe,
1162
- getSnapshot,
1163
- getServerSnapshot
1164
- );
1165
- };
1166
- react_production.useTransition = function () {
1167
- return ReactSharedInternals.H.useTransition();
1168
- };
1169
- react_production.version = "19.2.4";
1170
- return react_production;
144
+ function identify(userId, properties) {
145
+ trackerInstance?.identify(userId, properties);
1171
146
  }
1172
-
1173
- var react_development = {exports: {}};
1174
-
1175
- /**
1176
- * @license React
1177
- * react.development.js
1178
- *
1179
- * Copyright (c) Meta Platforms, Inc. and affiliates.
1180
- *
1181
- * This source code is licensed under the MIT license found in the
1182
- * LICENSE file in the root directory of this source tree.
1183
- */
1184
- react_development.exports;
1185
-
1186
- var hasRequiredReact_development;
1187
-
1188
- function requireReact_development () {
1189
- if (hasRequiredReact_development) return react_development.exports;
1190
- hasRequiredReact_development = 1;
1191
- (function (module, exports$1) {
1192
- "production" !== process.env.NODE_ENV &&
1193
- (function () {
1194
- function defineDeprecationWarning(methodName, info) {
1195
- Object.defineProperty(Component.prototype, methodName, {
1196
- get: function () {
1197
- console.warn(
1198
- "%s(...) is deprecated in plain JavaScript React classes. %s",
1199
- info[0],
1200
- info[1]
1201
- );
1202
- }
1203
- });
1204
- }
1205
- function getIteratorFn(maybeIterable) {
1206
- if (null === maybeIterable || "object" !== typeof maybeIterable)
1207
- return null;
1208
- maybeIterable =
1209
- (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
1210
- maybeIterable["@@iterator"];
1211
- return "function" === typeof maybeIterable ? maybeIterable : null;
1212
- }
1213
- function warnNoop(publicInstance, callerName) {
1214
- publicInstance =
1215
- ((publicInstance = publicInstance.constructor) &&
1216
- (publicInstance.displayName || publicInstance.name)) ||
1217
- "ReactClass";
1218
- var warningKey = publicInstance + "." + callerName;
1219
- didWarnStateUpdateForUnmountedComponent[warningKey] ||
1220
- (console.error(
1221
- "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.",
1222
- callerName,
1223
- publicInstance
1224
- ),
1225
- (didWarnStateUpdateForUnmountedComponent[warningKey] = true));
1226
- }
1227
- function Component(props, context, updater) {
1228
- this.props = props;
1229
- this.context = context;
1230
- this.refs = emptyObject;
1231
- this.updater = updater || ReactNoopUpdateQueue;
1232
- }
1233
- function ComponentDummy() {}
1234
- function PureComponent(props, context, updater) {
1235
- this.props = props;
1236
- this.context = context;
1237
- this.refs = emptyObject;
1238
- this.updater = updater || ReactNoopUpdateQueue;
1239
- }
1240
- function noop() {}
1241
- function testStringCoercion(value) {
1242
- return "" + value;
1243
- }
1244
- function checkKeyStringCoercion(value) {
1245
- try {
1246
- testStringCoercion(value);
1247
- var JSCompiler_inline_result = !1;
1248
- } catch (e) {
1249
- JSCompiler_inline_result = true;
1250
- }
1251
- if (JSCompiler_inline_result) {
1252
- JSCompiler_inline_result = console;
1253
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
1254
- var JSCompiler_inline_result$jscomp$0 =
1255
- ("function" === typeof Symbol &&
1256
- Symbol.toStringTag &&
1257
- value[Symbol.toStringTag]) ||
1258
- value.constructor.name ||
1259
- "Object";
1260
- JSCompiler_temp_const.call(
1261
- JSCompiler_inline_result,
1262
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
1263
- JSCompiler_inline_result$jscomp$0
1264
- );
1265
- return testStringCoercion(value);
1266
- }
1267
- }
1268
- function getComponentNameFromType(type) {
1269
- if (null == type) return null;
1270
- if ("function" === typeof type)
1271
- return type.$$typeof === REACT_CLIENT_REFERENCE
1272
- ? null
1273
- : type.displayName || type.name || null;
1274
- if ("string" === typeof type) return type;
1275
- switch (type) {
1276
- case REACT_FRAGMENT_TYPE:
1277
- return "Fragment";
1278
- case REACT_PROFILER_TYPE:
1279
- return "Profiler";
1280
- case REACT_STRICT_MODE_TYPE:
1281
- return "StrictMode";
1282
- case REACT_SUSPENSE_TYPE:
1283
- return "Suspense";
1284
- case REACT_SUSPENSE_LIST_TYPE:
1285
- return "SuspenseList";
1286
- case REACT_ACTIVITY_TYPE:
1287
- return "Activity";
1288
- }
1289
- if ("object" === typeof type)
1290
- switch (
1291
- ("number" === typeof type.tag &&
1292
- console.error(
1293
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
1294
- ),
1295
- type.$$typeof)
1296
- ) {
1297
- case REACT_PORTAL_TYPE:
1298
- return "Portal";
1299
- case REACT_CONTEXT_TYPE:
1300
- return type.displayName || "Context";
1301
- case REACT_CONSUMER_TYPE:
1302
- return (type._context.displayName || "Context") + ".Consumer";
1303
- case REACT_FORWARD_REF_TYPE:
1304
- var innerType = type.render;
1305
- type = type.displayName;
1306
- type ||
1307
- ((type = innerType.displayName || innerType.name || ""),
1308
- (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
1309
- return type;
1310
- case REACT_MEMO_TYPE:
1311
- return (
1312
- (innerType = type.displayName || null),
1313
- null !== innerType
1314
- ? innerType
1315
- : getComponentNameFromType(type.type) || "Memo"
1316
- );
1317
- case REACT_LAZY_TYPE:
1318
- innerType = type._payload;
1319
- type = type._init;
1320
- try {
1321
- return getComponentNameFromType(type(innerType));
1322
- } catch (x) {}
1323
- }
1324
- return null;
1325
- }
1326
- function getTaskName(type) {
1327
- if (type === REACT_FRAGMENT_TYPE) return "<>";
1328
- if (
1329
- "object" === typeof type &&
1330
- null !== type &&
1331
- type.$$typeof === REACT_LAZY_TYPE
1332
- )
1333
- return "<...>";
1334
- try {
1335
- var name = getComponentNameFromType(type);
1336
- return name ? "<" + name + ">" : "<...>";
1337
- } catch (x) {
1338
- return "<...>";
1339
- }
1340
- }
1341
- function getOwner() {
1342
- var dispatcher = ReactSharedInternals.A;
1343
- return null === dispatcher ? null : dispatcher.getOwner();
1344
- }
1345
- function UnknownOwner() {
1346
- return Error("react-stack-top-frame");
1347
- }
1348
- function hasValidKey(config) {
1349
- if (hasOwnProperty.call(config, "key")) {
1350
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
1351
- if (getter && getter.isReactWarning) return false;
1352
- }
1353
- return void 0 !== config.key;
1354
- }
1355
- function defineKeyPropWarningGetter(props, displayName) {
1356
- function warnAboutAccessingKey() {
1357
- specialPropKeyWarningShown ||
1358
- ((specialPropKeyWarningShown = true),
1359
- console.error(
1360
- "%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)",
1361
- displayName
1362
- ));
1363
- }
1364
- warnAboutAccessingKey.isReactWarning = true;
1365
- Object.defineProperty(props, "key", {
1366
- get: warnAboutAccessingKey,
1367
- configurable: true
1368
- });
1369
- }
1370
- function elementRefGetterWithDeprecationWarning() {
1371
- var componentName = getComponentNameFromType(this.type);
1372
- didWarnAboutElementRef[componentName] ||
1373
- ((didWarnAboutElementRef[componentName] = true),
1374
- console.error(
1375
- "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."
1376
- ));
1377
- componentName = this.props.ref;
1378
- return void 0 !== componentName ? componentName : null;
1379
- }
1380
- function ReactElement(type, key, props, owner, debugStack, debugTask) {
1381
- var refProp = props.ref;
1382
- type = {
1383
- $$typeof: REACT_ELEMENT_TYPE,
1384
- type: type,
1385
- key: key,
1386
- props: props,
1387
- _owner: owner
1388
- };
1389
- null !== (void 0 !== refProp ? refProp : null)
1390
- ? Object.defineProperty(type, "ref", {
1391
- enumerable: false,
1392
- get: elementRefGetterWithDeprecationWarning
1393
- })
1394
- : Object.defineProperty(type, "ref", { enumerable: false, value: null });
1395
- type._store = {};
1396
- Object.defineProperty(type._store, "validated", {
1397
- configurable: false,
1398
- enumerable: false,
1399
- writable: true,
1400
- value: 0
1401
- });
1402
- Object.defineProperty(type, "_debugInfo", {
1403
- configurable: false,
1404
- enumerable: false,
1405
- writable: true,
1406
- value: null
1407
- });
1408
- Object.defineProperty(type, "_debugStack", {
1409
- configurable: false,
1410
- enumerable: false,
1411
- writable: true,
1412
- value: debugStack
1413
- });
1414
- Object.defineProperty(type, "_debugTask", {
1415
- configurable: false,
1416
- enumerable: false,
1417
- writable: true,
1418
- value: debugTask
1419
- });
1420
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
1421
- return type;
1422
- }
1423
- function cloneAndReplaceKey(oldElement, newKey) {
1424
- newKey = ReactElement(
1425
- oldElement.type,
1426
- newKey,
1427
- oldElement.props,
1428
- oldElement._owner,
1429
- oldElement._debugStack,
1430
- oldElement._debugTask
1431
- );
1432
- oldElement._store &&
1433
- (newKey._store.validated = oldElement._store.validated);
1434
- return newKey;
1435
- }
1436
- function validateChildKeys(node) {
1437
- isValidElement(node)
1438
- ? node._store && (node._store.validated = 1)
1439
- : "object" === typeof node &&
1440
- null !== node &&
1441
- node.$$typeof === REACT_LAZY_TYPE &&
1442
- ("fulfilled" === node._payload.status
1443
- ? isValidElement(node._payload.value) &&
1444
- node._payload.value._store &&
1445
- (node._payload.value._store.validated = 1)
1446
- : node._store && (node._store.validated = 1));
1447
- }
1448
- function isValidElement(object) {
1449
- return (
1450
- "object" === typeof object &&
1451
- null !== object &&
1452
- object.$$typeof === REACT_ELEMENT_TYPE
1453
- );
1454
- }
1455
- function escape(key) {
1456
- var escaperLookup = { "=": "=0", ":": "=2" };
1457
- return (
1458
- "$" +
1459
- key.replace(/[=:]/g, function (match) {
1460
- return escaperLookup[match];
1461
- })
1462
- );
1463
- }
1464
- function getElementKey(element, index) {
1465
- return "object" === typeof element &&
1466
- null !== element &&
1467
- null != element.key
1468
- ? (checkKeyStringCoercion(element.key), escape("" + element.key))
1469
- : index.toString(36);
1470
- }
1471
- function resolveThenable(thenable) {
1472
- switch (thenable.status) {
1473
- case "fulfilled":
1474
- return thenable.value;
1475
- case "rejected":
1476
- throw thenable.reason;
1477
- default:
1478
- switch (
1479
- ("string" === typeof thenable.status
1480
- ? thenable.then(noop, noop)
1481
- : ((thenable.status = "pending"),
1482
- thenable.then(
1483
- function (fulfilledValue) {
1484
- "pending" === thenable.status &&
1485
- ((thenable.status = "fulfilled"),
1486
- (thenable.value = fulfilledValue));
1487
- },
1488
- function (error) {
1489
- "pending" === thenable.status &&
1490
- ((thenable.status = "rejected"),
1491
- (thenable.reason = error));
1492
- }
1493
- )),
1494
- thenable.status)
1495
- ) {
1496
- case "fulfilled":
1497
- return thenable.value;
1498
- case "rejected":
1499
- throw thenable.reason;
1500
- }
1501
- }
1502
- throw thenable;
1503
- }
1504
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1505
- var type = typeof children;
1506
- if ("undefined" === type || "boolean" === type) children = null;
1507
- var invokeCallback = false;
1508
- if (null === children) invokeCallback = true;
1509
- else
1510
- switch (type) {
1511
- case "bigint":
1512
- case "string":
1513
- case "number":
1514
- invokeCallback = true;
1515
- break;
1516
- case "object":
1517
- switch (children.$$typeof) {
1518
- case REACT_ELEMENT_TYPE:
1519
- case REACT_PORTAL_TYPE:
1520
- invokeCallback = true;
1521
- break;
1522
- case REACT_LAZY_TYPE:
1523
- return (
1524
- (invokeCallback = children._init),
1525
- mapIntoArray(
1526
- invokeCallback(children._payload),
1527
- array,
1528
- escapedPrefix,
1529
- nameSoFar,
1530
- callback
1531
- )
1532
- );
1533
- }
1534
- }
1535
- if (invokeCallback) {
1536
- invokeCallback = children;
1537
- callback = callback(invokeCallback);
1538
- var childKey =
1539
- "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
1540
- isArrayImpl(callback)
1541
- ? ((escapedPrefix = ""),
1542
- null != childKey &&
1543
- (escapedPrefix =
1544
- childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
1545
- mapIntoArray(callback, array, escapedPrefix, "", function (c) {
1546
- return c;
1547
- }))
1548
- : null != callback &&
1549
- (isValidElement(callback) &&
1550
- (null != callback.key &&
1551
- ((invokeCallback && invokeCallback.key === callback.key) ||
1552
- checkKeyStringCoercion(callback.key)),
1553
- (escapedPrefix = cloneAndReplaceKey(
1554
- callback,
1555
- escapedPrefix +
1556
- (null == callback.key ||
1557
- (invokeCallback && invokeCallback.key === callback.key)
1558
- ? ""
1559
- : ("" + callback.key).replace(
1560
- userProvidedKeyEscapeRegex,
1561
- "$&/"
1562
- ) + "/") +
1563
- childKey
1564
- )),
1565
- "" !== nameSoFar &&
1566
- null != invokeCallback &&
1567
- isValidElement(invokeCallback) &&
1568
- null == invokeCallback.key &&
1569
- invokeCallback._store &&
1570
- !invokeCallback._store.validated &&
1571
- (escapedPrefix._store.validated = 2),
1572
- (callback = escapedPrefix)),
1573
- array.push(callback));
1574
- return 1;
1575
- }
1576
- invokeCallback = 0;
1577
- childKey = "" === nameSoFar ? "." : nameSoFar + ":";
1578
- if (isArrayImpl(children))
1579
- for (var i = 0; i < children.length; i++)
1580
- (nameSoFar = children[i]),
1581
- (type = childKey + getElementKey(nameSoFar, i)),
1582
- (invokeCallback += mapIntoArray(
1583
- nameSoFar,
1584
- array,
1585
- escapedPrefix,
1586
- type,
1587
- callback
1588
- ));
1589
- else if (((i = getIteratorFn(children)), "function" === typeof i))
1590
- for (
1591
- i === children.entries &&
1592
- (didWarnAboutMaps ||
1593
- console.warn(
1594
- "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
1595
- ),
1596
- (didWarnAboutMaps = true)),
1597
- children = i.call(children),
1598
- i = 0;
1599
- !(nameSoFar = children.next()).done;
1600
-
1601
- )
1602
- (nameSoFar = nameSoFar.value),
1603
- (type = childKey + getElementKey(nameSoFar, i++)),
1604
- (invokeCallback += mapIntoArray(
1605
- nameSoFar,
1606
- array,
1607
- escapedPrefix,
1608
- type,
1609
- callback
1610
- ));
1611
- else if ("object" === type) {
1612
- if ("function" === typeof children.then)
1613
- return mapIntoArray(
1614
- resolveThenable(children),
1615
- array,
1616
- escapedPrefix,
1617
- nameSoFar,
1618
- callback
1619
- );
1620
- array = String(children);
1621
- throw Error(
1622
- "Objects are not valid as a React child (found: " +
1623
- ("[object Object]" === array
1624
- ? "object with keys {" + Object.keys(children).join(", ") + "}"
1625
- : array) +
1626
- "). If you meant to render a collection of children, use an array instead."
1627
- );
1628
- }
1629
- return invokeCallback;
1630
- }
1631
- function mapChildren(children, func, context) {
1632
- if (null == children) return children;
1633
- var result = [],
1634
- count = 0;
1635
- mapIntoArray(children, result, "", "", function (child) {
1636
- return func.call(context, child, count++);
1637
- });
1638
- return result;
1639
- }
1640
- function lazyInitializer(payload) {
1641
- if (-1 === payload._status) {
1642
- var ioInfo = payload._ioInfo;
1643
- null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
1644
- ioInfo = payload._result;
1645
- var thenable = ioInfo();
1646
- thenable.then(
1647
- function (moduleObject) {
1648
- if (0 === payload._status || -1 === payload._status) {
1649
- payload._status = 1;
1650
- payload._result = moduleObject;
1651
- var _ioInfo = payload._ioInfo;
1652
- null != _ioInfo && (_ioInfo.end = performance.now());
1653
- void 0 === thenable.status &&
1654
- ((thenable.status = "fulfilled"),
1655
- (thenable.value = moduleObject));
1656
- }
1657
- },
1658
- function (error) {
1659
- if (0 === payload._status || -1 === payload._status) {
1660
- payload._status = 2;
1661
- payload._result = error;
1662
- var _ioInfo2 = payload._ioInfo;
1663
- null != _ioInfo2 && (_ioInfo2.end = performance.now());
1664
- void 0 === thenable.status &&
1665
- ((thenable.status = "rejected"), (thenable.reason = error));
1666
- }
1667
- }
1668
- );
1669
- ioInfo = payload._ioInfo;
1670
- if (null != ioInfo) {
1671
- ioInfo.value = thenable;
1672
- var displayName = thenable.displayName;
1673
- "string" === typeof displayName && (ioInfo.name = displayName);
1674
- }
1675
- -1 === payload._status &&
1676
- ((payload._status = 0), (payload._result = thenable));
1677
- }
1678
- if (1 === payload._status)
1679
- return (
1680
- (ioInfo = payload._result),
1681
- void 0 === ioInfo &&
1682
- console.error(
1683
- "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?",
1684
- ioInfo
1685
- ),
1686
- "default" in ioInfo ||
1687
- console.error(
1688
- "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
1689
- ioInfo
1690
- ),
1691
- ioInfo.default
1692
- );
1693
- throw payload._result;
1694
- }
1695
- function resolveDispatcher() {
1696
- var dispatcher = ReactSharedInternals.H;
1697
- null === dispatcher &&
1698
- console.error(
1699
- "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."
1700
- );
1701
- return dispatcher;
1702
- }
1703
- function releaseAsyncTransition() {
1704
- ReactSharedInternals.asyncTransitions--;
1705
- }
1706
- function enqueueTask(task) {
1707
- if (null === enqueueTaskImpl)
1708
- try {
1709
- var requireString = ("require" + Math.random()).slice(0, 7);
1710
- enqueueTaskImpl = (module && module[requireString]).call(
1711
- module,
1712
- "timers"
1713
- ).setImmediate;
1714
- } catch (_err) {
1715
- enqueueTaskImpl = function (callback) {
1716
- false === didWarnAboutMessageChannel &&
1717
- ((didWarnAboutMessageChannel = true),
1718
- "undefined" === typeof MessageChannel &&
1719
- console.error(
1720
- "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."
1721
- ));
1722
- var channel = new MessageChannel();
1723
- channel.port1.onmessage = callback;
1724
- channel.port2.postMessage(void 0);
1725
- };
1726
- }
1727
- return enqueueTaskImpl(task);
1728
- }
1729
- function aggregateErrors(errors) {
1730
- return 1 < errors.length && "function" === typeof AggregateError
1731
- ? new AggregateError(errors)
1732
- : errors[0];
1733
- }
1734
- function popActScope(prevActQueue, prevActScopeDepth) {
1735
- prevActScopeDepth !== actScopeDepth - 1 &&
1736
- console.error(
1737
- "You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
1738
- );
1739
- actScopeDepth = prevActScopeDepth;
1740
- }
1741
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
1742
- var queue = ReactSharedInternals.actQueue;
1743
- if (null !== queue)
1744
- if (0 !== queue.length)
1745
- try {
1746
- flushActQueue(queue);
1747
- enqueueTask(function () {
1748
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
1749
- });
1750
- return;
1751
- } catch (error) {
1752
- ReactSharedInternals.thrownErrors.push(error);
1753
- }
1754
- else ReactSharedInternals.actQueue = null;
1755
- 0 < ReactSharedInternals.thrownErrors.length
1756
- ? ((queue = aggregateErrors(ReactSharedInternals.thrownErrors)),
1757
- (ReactSharedInternals.thrownErrors.length = 0),
1758
- reject(queue))
1759
- : resolve(returnValue);
1760
- }
1761
- function flushActQueue(queue) {
1762
- if (!isFlushing) {
1763
- isFlushing = true;
1764
- var i = 0;
1765
- try {
1766
- for (; i < queue.length; i++) {
1767
- var callback = queue[i];
1768
- do {
1769
- ReactSharedInternals.didUsePromise = !1;
1770
- var continuation = callback(!1);
1771
- if (null !== continuation) {
1772
- if (ReactSharedInternals.didUsePromise) {
1773
- queue[i] = callback;
1774
- queue.splice(0, i);
1775
- return;
1776
- }
1777
- callback = continuation;
1778
- } else break;
1779
- } while (1);
1780
- }
1781
- queue.length = 0;
1782
- } catch (error) {
1783
- queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
1784
- } finally {
1785
- isFlushing = false;
1786
- }
1787
- }
1788
- }
1789
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1790
- "function" ===
1791
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
1792
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1793
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
1794
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
1795
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
1796
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
1797
- REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
1798
- REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
1799
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
1800
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
1801
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
1802
- REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
1803
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
1804
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
1805
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
1806
- MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
1807
- didWarnStateUpdateForUnmountedComponent = {},
1808
- ReactNoopUpdateQueue = {
1809
- isMounted: function () {
1810
- return false;
1811
- },
1812
- enqueueForceUpdate: function (publicInstance) {
1813
- warnNoop(publicInstance, "forceUpdate");
1814
- },
1815
- enqueueReplaceState: function (publicInstance) {
1816
- warnNoop(publicInstance, "replaceState");
1817
- },
1818
- enqueueSetState: function (publicInstance) {
1819
- warnNoop(publicInstance, "setState");
1820
- }
1821
- },
1822
- assign = Object.assign,
1823
- emptyObject = {};
1824
- Object.freeze(emptyObject);
1825
- Component.prototype.isReactComponent = {};
1826
- Component.prototype.setState = function (partialState, callback) {
1827
- if (
1828
- "object" !== typeof partialState &&
1829
- "function" !== typeof partialState &&
1830
- null != partialState
1831
- )
1832
- throw Error(
1833
- "takes an object of state variables to update or a function which returns an object of state variables."
1834
- );
1835
- this.updater.enqueueSetState(this, partialState, callback, "setState");
1836
- };
1837
- Component.prototype.forceUpdate = function (callback) {
1838
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
1839
- };
1840
- var deprecatedAPIs = {
1841
- isMounted: [
1842
- "isMounted",
1843
- "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
1844
- ],
1845
- replaceState: [
1846
- "replaceState",
1847
- "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
1848
- ]
1849
- };
1850
- for (fnName in deprecatedAPIs)
1851
- deprecatedAPIs.hasOwnProperty(fnName) &&
1852
- defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
1853
- ComponentDummy.prototype = Component.prototype;
1854
- deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
1855
- deprecatedAPIs.constructor = PureComponent;
1856
- assign(deprecatedAPIs, Component.prototype);
1857
- deprecatedAPIs.isPureReactComponent = true;
1858
- var isArrayImpl = Array.isArray,
1859
- REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
1860
- ReactSharedInternals = {
1861
- H: null,
1862
- A: null,
1863
- T: null,
1864
- S: null,
1865
- actQueue: null,
1866
- asyncTransitions: 0,
1867
- isBatchingLegacy: false,
1868
- didScheduleLegacyUpdate: false,
1869
- didUsePromise: false,
1870
- thrownErrors: [],
1871
- getCurrentStack: null,
1872
- recentlyCreatedOwnerStacks: 0
1873
- },
1874
- hasOwnProperty = Object.prototype.hasOwnProperty,
1875
- createTask = console.createTask
1876
- ? console.createTask
1877
- : function () {
1878
- return null;
1879
- };
1880
- deprecatedAPIs = {
1881
- react_stack_bottom_frame: function (callStackForError) {
1882
- return callStackForError();
1883
- }
1884
- };
1885
- var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
1886
- var didWarnAboutElementRef = {};
1887
- var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
1888
- deprecatedAPIs,
1889
- UnknownOwner
1890
- )();
1891
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1892
- var didWarnAboutMaps = false,
1893
- userProvidedKeyEscapeRegex = /\/+/g,
1894
- reportGlobalError =
1895
- "function" === typeof reportError
1896
- ? reportError
1897
- : function (error) {
1898
- if (
1899
- "object" === typeof window &&
1900
- "function" === typeof window.ErrorEvent
1901
- ) {
1902
- var event = new window.ErrorEvent("error", {
1903
- bubbles: true,
1904
- cancelable: true,
1905
- message:
1906
- "object" === typeof error &&
1907
- null !== error &&
1908
- "string" === typeof error.message
1909
- ? String(error.message)
1910
- : String(error),
1911
- error: error
1912
- });
1913
- if (!window.dispatchEvent(event)) return;
1914
- } else if (
1915
- "object" === typeof process &&
1916
- "function" === typeof process.emit
1917
- ) {
1918
- process.emit("uncaughtException", error);
1919
- return;
1920
- }
1921
- console.error(error);
1922
- },
1923
- didWarnAboutMessageChannel = false,
1924
- enqueueTaskImpl = null,
1925
- actScopeDepth = 0,
1926
- didWarnNoAwaitAct = false,
1927
- isFlushing = false,
1928
- queueSeveralMicrotasks =
1929
- "function" === typeof queueMicrotask
1930
- ? function (callback) {
1931
- queueMicrotask(function () {
1932
- return queueMicrotask(callback);
1933
- });
1934
- }
1935
- : enqueueTask;
1936
- deprecatedAPIs = Object.freeze({
1937
- __proto__: null,
1938
- c: function (size) {
1939
- return resolveDispatcher().useMemoCache(size);
1940
- }
1941
- });
1942
- var fnName = {
1943
- map: mapChildren,
1944
- forEach: function (children, forEachFunc, forEachContext) {
1945
- mapChildren(
1946
- children,
1947
- function () {
1948
- forEachFunc.apply(this, arguments);
1949
- },
1950
- forEachContext
1951
- );
1952
- },
1953
- count: function (children) {
1954
- var n = 0;
1955
- mapChildren(children, function () {
1956
- n++;
1957
- });
1958
- return n;
1959
- },
1960
- toArray: function (children) {
1961
- return (
1962
- mapChildren(children, function (child) {
1963
- return child;
1964
- }) || []
1965
- );
1966
- },
1967
- only: function (children) {
1968
- if (!isValidElement(children))
1969
- throw Error(
1970
- "React.Children.only expected to receive a single React element child."
1971
- );
1972
- return children;
1973
- }
1974
- };
1975
- exports$1.Activity = REACT_ACTIVITY_TYPE;
1976
- exports$1.Children = fnName;
1977
- exports$1.Component = Component;
1978
- exports$1.Fragment = REACT_FRAGMENT_TYPE;
1979
- exports$1.Profiler = REACT_PROFILER_TYPE;
1980
- exports$1.PureComponent = PureComponent;
1981
- exports$1.StrictMode = REACT_STRICT_MODE_TYPE;
1982
- exports$1.Suspense = REACT_SUSPENSE_TYPE;
1983
- exports$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
1984
- ReactSharedInternals;
1985
- exports$1.__COMPILER_RUNTIME = deprecatedAPIs;
1986
- exports$1.act = function (callback) {
1987
- var prevActQueue = ReactSharedInternals.actQueue,
1988
- prevActScopeDepth = actScopeDepth;
1989
- actScopeDepth++;
1990
- var queue = (ReactSharedInternals.actQueue =
1991
- null !== prevActQueue ? prevActQueue : []),
1992
- didAwaitActCall = false;
1993
- try {
1994
- var result = callback();
1995
- } catch (error) {
1996
- ReactSharedInternals.thrownErrors.push(error);
1997
- }
1998
- if (0 < ReactSharedInternals.thrownErrors.length)
1999
- throw (
2000
- (popActScope(prevActQueue, prevActScopeDepth),
2001
- (callback = aggregateErrors(ReactSharedInternals.thrownErrors)),
2002
- (ReactSharedInternals.thrownErrors.length = 0),
2003
- callback)
2004
- );
2005
- if (
2006
- null !== result &&
2007
- "object" === typeof result &&
2008
- "function" === typeof result.then
2009
- ) {
2010
- var thenable = result;
2011
- queueSeveralMicrotasks(function () {
2012
- didAwaitActCall ||
2013
- didWarnNoAwaitAct ||
2014
- ((didWarnNoAwaitAct = true),
2015
- console.error(
2016
- "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 () => ...);"
2017
- ));
2018
- });
2019
- return {
2020
- then: function (resolve, reject) {
2021
- didAwaitActCall = true;
2022
- thenable.then(
2023
- function (returnValue) {
2024
- popActScope(prevActQueue, prevActScopeDepth);
2025
- if (0 === prevActScopeDepth) {
2026
- try {
2027
- flushActQueue(queue),
2028
- enqueueTask(function () {
2029
- return recursivelyFlushAsyncActWork(
2030
- returnValue,
2031
- resolve,
2032
- reject
2033
- );
2034
- });
2035
- } catch (error$0) {
2036
- ReactSharedInternals.thrownErrors.push(error$0);
2037
- }
2038
- if (0 < ReactSharedInternals.thrownErrors.length) {
2039
- var _thrownError = aggregateErrors(
2040
- ReactSharedInternals.thrownErrors
2041
- );
2042
- ReactSharedInternals.thrownErrors.length = 0;
2043
- reject(_thrownError);
2044
- }
2045
- } else resolve(returnValue);
2046
- },
2047
- function (error) {
2048
- popActScope(prevActQueue, prevActScopeDepth);
2049
- 0 < ReactSharedInternals.thrownErrors.length
2050
- ? ((error = aggregateErrors(
2051
- ReactSharedInternals.thrownErrors
2052
- )),
2053
- (ReactSharedInternals.thrownErrors.length = 0),
2054
- reject(error))
2055
- : reject(error);
2056
- }
2057
- );
2058
- }
2059
- };
2060
- }
2061
- var returnValue$jscomp$0 = result;
2062
- popActScope(prevActQueue, prevActScopeDepth);
2063
- 0 === prevActScopeDepth &&
2064
- (flushActQueue(queue),
2065
- 0 !== queue.length &&
2066
- queueSeveralMicrotasks(function () {
2067
- didAwaitActCall ||
2068
- didWarnNoAwaitAct ||
2069
- ((didWarnNoAwaitAct = true),
2070
- console.error(
2071
- "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(() => ...)"
2072
- ));
2073
- }),
2074
- (ReactSharedInternals.actQueue = null));
2075
- if (0 < ReactSharedInternals.thrownErrors.length)
2076
- throw (
2077
- ((callback = aggregateErrors(ReactSharedInternals.thrownErrors)),
2078
- (ReactSharedInternals.thrownErrors.length = 0),
2079
- callback)
2080
- );
2081
- return {
2082
- then: function (resolve, reject) {
2083
- didAwaitActCall = true;
2084
- 0 === prevActScopeDepth
2085
- ? ((ReactSharedInternals.actQueue = queue),
2086
- enqueueTask(function () {
2087
- return recursivelyFlushAsyncActWork(
2088
- returnValue$jscomp$0,
2089
- resolve,
2090
- reject
2091
- );
2092
- }))
2093
- : resolve(returnValue$jscomp$0);
2094
- }
2095
- };
2096
- };
2097
- exports$1.cache = function (fn) {
2098
- return function () {
2099
- return fn.apply(null, arguments);
2100
- };
2101
- };
2102
- exports$1.cacheSignal = function () {
2103
- return null;
2104
- };
2105
- exports$1.captureOwnerStack = function () {
2106
- var getCurrentStack = ReactSharedInternals.getCurrentStack;
2107
- return null === getCurrentStack ? null : getCurrentStack();
2108
- };
2109
- exports$1.cloneElement = function (element, config, children) {
2110
- if (null === element || void 0 === element)
2111
- throw Error(
2112
- "The argument must be a React element, but you passed " +
2113
- element +
2114
- "."
2115
- );
2116
- var props = assign({}, element.props),
2117
- key = element.key,
2118
- owner = element._owner;
2119
- if (null != config) {
2120
- var JSCompiler_inline_result;
2121
- a: {
2122
- if (
2123
- hasOwnProperty.call(config, "ref") &&
2124
- (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
2125
- config,
2126
- "ref"
2127
- ).get) &&
2128
- JSCompiler_inline_result.isReactWarning
2129
- ) {
2130
- JSCompiler_inline_result = false;
2131
- break a;
2132
- }
2133
- JSCompiler_inline_result = void 0 !== config.ref;
2134
- }
2135
- JSCompiler_inline_result && (owner = getOwner());
2136
- hasValidKey(config) &&
2137
- (checkKeyStringCoercion(config.key), (key = "" + config.key));
2138
- for (propName in config)
2139
- !hasOwnProperty.call(config, propName) ||
2140
- "key" === propName ||
2141
- "__self" === propName ||
2142
- "__source" === propName ||
2143
- ("ref" === propName && void 0 === config.ref) ||
2144
- (props[propName] = config[propName]);
2145
- }
2146
- var propName = arguments.length - 2;
2147
- if (1 === propName) props.children = children;
2148
- else if (1 < propName) {
2149
- JSCompiler_inline_result = Array(propName);
2150
- for (var i = 0; i < propName; i++)
2151
- JSCompiler_inline_result[i] = arguments[i + 2];
2152
- props.children = JSCompiler_inline_result;
2153
- }
2154
- props = ReactElement(
2155
- element.type,
2156
- key,
2157
- props,
2158
- owner,
2159
- element._debugStack,
2160
- element._debugTask
2161
- );
2162
- for (key = 2; key < arguments.length; key++)
2163
- validateChildKeys(arguments[key]);
2164
- return props;
2165
- };
2166
- exports$1.createContext = function (defaultValue) {
2167
- defaultValue = {
2168
- $$typeof: REACT_CONTEXT_TYPE,
2169
- _currentValue: defaultValue,
2170
- _currentValue2: defaultValue,
2171
- _threadCount: 0,
2172
- Provider: null,
2173
- Consumer: null
2174
- };
2175
- defaultValue.Provider = defaultValue;
2176
- defaultValue.Consumer = {
2177
- $$typeof: REACT_CONSUMER_TYPE,
2178
- _context: defaultValue
2179
- };
2180
- defaultValue._currentRenderer = null;
2181
- defaultValue._currentRenderer2 = null;
2182
- return defaultValue;
2183
- };
2184
- exports$1.createElement = function (type, config, children) {
2185
- for (var i = 2; i < arguments.length; i++)
2186
- validateChildKeys(arguments[i]);
2187
- i = {};
2188
- var key = null;
2189
- if (null != config)
2190
- for (propName in (didWarnAboutOldJSXRuntime ||
2191
- !("__self" in config) ||
2192
- "key" in config ||
2193
- ((didWarnAboutOldJSXRuntime = true),
2194
- console.warn(
2195
- "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"
2196
- )),
2197
- hasValidKey(config) &&
2198
- (checkKeyStringCoercion(config.key), (key = "" + config.key)),
2199
- config))
2200
- hasOwnProperty.call(config, propName) &&
2201
- "key" !== propName &&
2202
- "__self" !== propName &&
2203
- "__source" !== propName &&
2204
- (i[propName] = config[propName]);
2205
- var childrenLength = arguments.length - 2;
2206
- if (1 === childrenLength) i.children = children;
2207
- else if (1 < childrenLength) {
2208
- for (
2209
- var childArray = Array(childrenLength), _i = 0;
2210
- _i < childrenLength;
2211
- _i++
2212
- )
2213
- childArray[_i] = arguments[_i + 2];
2214
- Object.freeze && Object.freeze(childArray);
2215
- i.children = childArray;
2216
- }
2217
- if (type && type.defaultProps)
2218
- for (propName in ((childrenLength = type.defaultProps), childrenLength))
2219
- void 0 === i[propName] && (i[propName] = childrenLength[propName]);
2220
- key &&
2221
- defineKeyPropWarningGetter(
2222
- i,
2223
- "function" === typeof type
2224
- ? type.displayName || type.name || "Unknown"
2225
- : type
2226
- );
2227
- var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
2228
- return ReactElement(
2229
- type,
2230
- key,
2231
- i,
2232
- getOwner(),
2233
- propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
2234
- propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
2235
- );
2236
- };
2237
- exports$1.createRef = function () {
2238
- var refObject = { current: null };
2239
- Object.seal(refObject);
2240
- return refObject;
2241
- };
2242
- exports$1.forwardRef = function (render) {
2243
- null != render && render.$$typeof === REACT_MEMO_TYPE
2244
- ? console.error(
2245
- "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
2246
- )
2247
- : "function" !== typeof render
2248
- ? console.error(
2249
- "forwardRef requires a render function but was given %s.",
2250
- null === render ? "null" : typeof render
2251
- )
2252
- : 0 !== render.length &&
2253
- 2 !== render.length &&
2254
- console.error(
2255
- "forwardRef render functions accept exactly two parameters: props and ref. %s",
2256
- 1 === render.length
2257
- ? "Did you forget to use the ref parameter?"
2258
- : "Any additional parameter will be undefined."
2259
- );
2260
- null != render &&
2261
- null != render.defaultProps &&
2262
- console.error(
2263
- "forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
2264
- );
2265
- var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render: render },
2266
- ownName;
2267
- Object.defineProperty(elementType, "displayName", {
2268
- enumerable: false,
2269
- configurable: true,
2270
- get: function () {
2271
- return ownName;
2272
- },
2273
- set: function (name) {
2274
- ownName = name;
2275
- render.name ||
2276
- render.displayName ||
2277
- (Object.defineProperty(render, "name", { value: name }),
2278
- (render.displayName = name));
2279
- }
2280
- });
2281
- return elementType;
2282
- };
2283
- exports$1.isValidElement = isValidElement;
2284
- exports$1.lazy = function (ctor) {
2285
- ctor = { _status: -1, _result: ctor };
2286
- var lazyType = {
2287
- $$typeof: REACT_LAZY_TYPE,
2288
- _payload: ctor,
2289
- _init: lazyInitializer
2290
- },
2291
- ioInfo = {
2292
- name: "lazy",
2293
- start: -1,
2294
- end: -1,
2295
- value: null,
2296
- owner: null,
2297
- debugStack: Error("react-stack-top-frame"),
2298
- debugTask: console.createTask ? console.createTask("lazy()") : null
2299
- };
2300
- ctor._ioInfo = ioInfo;
2301
- lazyType._debugInfo = [{ awaited: ioInfo }];
2302
- return lazyType;
2303
- };
2304
- exports$1.memo = function (type, compare) {
2305
- null == type &&
2306
- console.error(
2307
- "memo: The first argument must be a component. Instead received: %s",
2308
- null === type ? "null" : typeof type
2309
- );
2310
- compare = {
2311
- $$typeof: REACT_MEMO_TYPE,
2312
- type: type,
2313
- compare: void 0 === compare ? null : compare
2314
- };
2315
- var ownName;
2316
- Object.defineProperty(compare, "displayName", {
2317
- enumerable: false,
2318
- configurable: true,
2319
- get: function () {
2320
- return ownName;
2321
- },
2322
- set: function (name) {
2323
- ownName = name;
2324
- type.name ||
2325
- type.displayName ||
2326
- (Object.defineProperty(type, "name", { value: name }),
2327
- (type.displayName = name));
2328
- }
2329
- });
2330
- return compare;
2331
- };
2332
- exports$1.startTransition = function (scope) {
2333
- var prevTransition = ReactSharedInternals.T,
2334
- currentTransition = {};
2335
- currentTransition._updatedFibers = new Set();
2336
- ReactSharedInternals.T = currentTransition;
2337
- try {
2338
- var returnValue = scope(),
2339
- onStartTransitionFinish = ReactSharedInternals.S;
2340
- null !== onStartTransitionFinish &&
2341
- onStartTransitionFinish(currentTransition, returnValue);
2342
- "object" === typeof returnValue &&
2343
- null !== returnValue &&
2344
- "function" === typeof returnValue.then &&
2345
- (ReactSharedInternals.asyncTransitions++,
2346
- returnValue.then(releaseAsyncTransition, releaseAsyncTransition),
2347
- returnValue.then(noop, reportGlobalError));
2348
- } catch (error) {
2349
- reportGlobalError(error);
2350
- } finally {
2351
- null === prevTransition &&
2352
- currentTransition._updatedFibers &&
2353
- ((scope = currentTransition._updatedFibers.size),
2354
- currentTransition._updatedFibers.clear(),
2355
- 10 < scope &&
2356
- console.warn(
2357
- "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."
2358
- )),
2359
- null !== prevTransition &&
2360
- null !== currentTransition.types &&
2361
- (null !== prevTransition.types &&
2362
- prevTransition.types !== currentTransition.types &&
2363
- console.error(
2364
- "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."
2365
- ),
2366
- (prevTransition.types = currentTransition.types)),
2367
- (ReactSharedInternals.T = prevTransition);
2368
- }
2369
- };
2370
- exports$1.unstable_useCacheRefresh = function () {
2371
- return resolveDispatcher().useCacheRefresh();
2372
- };
2373
- exports$1.use = function (usable) {
2374
- return resolveDispatcher().use(usable);
2375
- };
2376
- exports$1.useActionState = function (action, initialState, permalink) {
2377
- return resolveDispatcher().useActionState(
2378
- action,
2379
- initialState,
2380
- permalink
2381
- );
2382
- };
2383
- exports$1.useCallback = function (callback, deps) {
2384
- return resolveDispatcher().useCallback(callback, deps);
2385
- };
2386
- exports$1.useContext = function (Context) {
2387
- var dispatcher = resolveDispatcher();
2388
- Context.$$typeof === REACT_CONSUMER_TYPE &&
2389
- console.error(
2390
- "Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
2391
- );
2392
- return dispatcher.useContext(Context);
2393
- };
2394
- exports$1.useDebugValue = function (value, formatterFn) {
2395
- return resolveDispatcher().useDebugValue(value, formatterFn);
2396
- };
2397
- exports$1.useDeferredValue = function (value, initialValue) {
2398
- return resolveDispatcher().useDeferredValue(value, initialValue);
2399
- };
2400
- exports$1.useEffect = function (create, deps) {
2401
- null == create &&
2402
- console.warn(
2403
- "React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2404
- );
2405
- return resolveDispatcher().useEffect(create, deps);
2406
- };
2407
- exports$1.useEffectEvent = function (callback) {
2408
- return resolveDispatcher().useEffectEvent(callback);
2409
- };
2410
- exports$1.useId = function () {
2411
- return resolveDispatcher().useId();
2412
- };
2413
- exports$1.useImperativeHandle = function (ref, create, deps) {
2414
- return resolveDispatcher().useImperativeHandle(ref, create, deps);
2415
- };
2416
- exports$1.useInsertionEffect = function (create, deps) {
2417
- null == create &&
2418
- console.warn(
2419
- "React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2420
- );
2421
- return resolveDispatcher().useInsertionEffect(create, deps);
2422
- };
2423
- exports$1.useLayoutEffect = function (create, deps) {
2424
- null == create &&
2425
- console.warn(
2426
- "React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2427
- );
2428
- return resolveDispatcher().useLayoutEffect(create, deps);
2429
- };
2430
- exports$1.useMemo = function (create, deps) {
2431
- return resolveDispatcher().useMemo(create, deps);
2432
- };
2433
- exports$1.useOptimistic = function (passthrough, reducer) {
2434
- return resolveDispatcher().useOptimistic(passthrough, reducer);
2435
- };
2436
- exports$1.useReducer = function (reducer, initialArg, init) {
2437
- return resolveDispatcher().useReducer(reducer, initialArg, init);
2438
- };
2439
- exports$1.useRef = function (initialValue) {
2440
- return resolveDispatcher().useRef(initialValue);
2441
- };
2442
- exports$1.useState = function (initialState) {
2443
- return resolveDispatcher().useState(initialState);
2444
- };
2445
- exports$1.useSyncExternalStore = function (
2446
- subscribe,
2447
- getSnapshot,
2448
- getServerSnapshot
2449
- ) {
2450
- return resolveDispatcher().useSyncExternalStore(
2451
- subscribe,
2452
- getSnapshot,
2453
- getServerSnapshot
2454
- );
2455
- };
2456
- exports$1.useTransition = function () {
2457
- return resolveDispatcher().useTransition();
2458
- };
2459
- exports$1.version = "19.2.4";
2460
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2461
- "function" ===
2462
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
2463
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
2464
- })();
2465
- } (react_development, react_development.exports));
2466
- return react_development.exports;
147
+ function track(eventName, properties) {
148
+ trackerInstance?.track(eventName, properties);
2467
149
  }
2468
-
2469
- if (process.env.NODE_ENV === 'production') {
2470
- react.exports = requireReact_production();
2471
- } else {
2472
- react.exports = requireReact_development();
150
+ function page(pageName, properties) {
151
+ trackerInstance?.page(pageName, properties);
2473
152
  }
2474
-
2475
- var reactExports = react.exports;
2476
- var React = /*@__PURE__*/getDefaultExportFromCjs(reactExports);
2477
-
2478
- /**
2479
- * ATHENA OTA Wrapper
2480
- *
2481
- * Wraps the React Native app and forces a reload on first launch after OTA update
2482
- * This ensures the ATHENA tracker is loaded fresh after deployment
2483
- *
2484
- * Usage:
2485
- * import { AthenaOTAWrapper } from '@athena/tracker';
2486
- *
2487
- * export default function App() {
2488
- * return (
2489
- * <AthenaOTAWrapper>
2490
- * <YourAppContent />
2491
- * </AthenaOTAWrapper>
2492
- * );
2493
- * }
2494
- */
2495
- // Dynamic import of expo-updates (optional peer dependency)
2496
- let Updates = null;
2497
- async function loadExpoUpdates() {
2498
- try {
2499
- Updates = await import('expo-updates');
2500
- return true;
2501
- } catch (error) {
2502
- console.warn('[ATHENA] expo-updates not available - OTA updates disabled');
2503
- return false;
2504
- }
153
+ function reset() {
154
+ trackerInstance?.reset();
2505
155
  }
2506
- function AthenaOTAWrapper({
2507
- children,
2508
- loadingMessage = 'Loading...',
2509
- updateMessage = 'Updating...'
2510
- }) {
2511
- const [isCheckingUpdate, setIsCheckingUpdate] = reactExports.useState(true);
2512
- const [updateAvailable, setUpdateAvailable] = reactExports.useState(false);
2513
- const [error, setError] = reactExports.useState(null);
2514
- reactExports.useEffect(() => {
2515
- checkForUpdates();
2516
- }, []);
2517
- async function checkForUpdates() {
2518
- try {
2519
- // Load expo-updates module
2520
- const hasUpdates = await loadExpoUpdates();
2521
- if (!hasUpdates) {
2522
- // expo-updates not available, continue without OTA check
2523
- setIsCheckingUpdate(false);
2524
- return;
2525
- }
2526
- // Check if running in development mode (skip update check)
2527
- if (__DEV__) {
2528
- console.log('[ATHENA] Development mode - skipping OTA update check');
2529
- setIsCheckingUpdate(false);
2530
- return;
2531
- }
2532
- console.log('[ATHENA] Checking for OTA updates...');
2533
- // Check for available updates
2534
- const update = await Updates.checkForUpdateAsync();
2535
- if (update.isAvailable) {
2536
- console.log('[ATHENA] Update available - fetching...');
2537
- setUpdateAvailable(true);
2538
- // Fetch the new update
2539
- await Updates.fetchUpdateAsync();
2540
- console.log('[ATHENA] Update fetched - reloading app...');
2541
- // Force reload to apply update
2542
- await Updates.reloadAsync();
2543
- // If reloadAsync fails, we'll never reach here
2544
- } else {
2545
- console.log('[ATHENA] No updates available - continuing with current version');
2546
- setIsCheckingUpdate(false);
2547
- }
2548
- } catch (error) {
2549
- // Don't block app if update check fails
2550
- console.warn('[ATHENA] Update check failed:', error.message);
2551
- setError(error.message);
2552
- setIsCheckingUpdate(false);
2553
- }
2554
- }
2555
- // Show loading screen while checking for updates
2556
- if (isCheckingUpdate || updateAvailable) {
2557
- return React.createElement(View, {
2558
- style: styles.container
2559
- }, React.createElement(ActivityIndicator, {
2560
- size: "large",
2561
- color: "#007AFF"
2562
- }), React.createElement(Text, {
2563
- style: styles.text
2564
- }, updateAvailable ? updateMessage : loadingMessage), error && React.createElement(Text, {
2565
- style: styles.errorText
2566
- }, "Update check failed: ", error));
2567
- }
2568
- // Render app content once update check is complete
2569
- return React.createElement(React.Fragment, null, children);
156
+ function getSessionId() {
157
+ return trackerInstance?.getSessionId() || null;
2570
158
  }
2571
- const styles = StyleSheet.create({
2572
- container: {
2573
- flex: 1,
2574
- justifyContent: 'center',
2575
- alignItems: 'center',
2576
- backgroundColor: '#FFFFFF'
2577
- },
2578
- text: {
2579
- marginTop: 16,
2580
- color: '#666666',
2581
- fontSize: 14,
2582
- fontWeight: '500'
2583
- },
2584
- errorText: {
2585
- marginTop: 8,
2586
- color: '#FF3B30',
2587
- fontSize: 12,
2588
- textAlign: 'center',
2589
- paddingHorizontal: 32
2590
- }
2591
- });
2592
-
2593
- /**
2594
- * React Native Event Capture
2595
- *
2596
- * Captures behavioral events from React Native apps
2597
- * - Touch events (Tap, Swipe, LongPress)
2598
- * - Navigation events (Screen changes)
2599
- * - App lifecycle events (Open, Background, Foreground, Close)
2600
- * - Form interactions
2601
- * - Network errors
2602
- */
2603
- class ReactNativeEventCapture {
2604
- constructor(config = {}) {
2605
- this.events = [];
2606
- this.appStateSubscription = null;
2607
- this.panResponder = null;
2608
- this.batchTimer = null;
2609
- this.currentScreen = 'Unknown';
2610
- this.sessionStartTime = Date.now();
2611
- this.config = {
2612
- captureTouch: config.captureTouch !== false,
2613
- captureNavigation: config.captureNavigation !== false,
2614
- captureLifecycle: config.captureLifecycle !== false,
2615
- captureNetworkErrors: config.captureNetworkErrors !== false,
2616
- batchSize: config.batchSize || 10,
2617
- batchIntervalMs: config.batchIntervalMs || 10000
2618
- };
2619
- }
2620
- /**
2621
- * Start capturing events
2622
- */
2623
- start() {
2624
- console.log('[ATHENA] Starting React Native event capture');
2625
- if (this.config.captureLifecycle) {
2626
- this.setupLifecycleTracking();
2627
- }
2628
- if (this.config.captureTouch) {
2629
- this.setupTouchTracking();
2630
- }
2631
- if (this.config.captureNetworkErrors) {
2632
- this.setupNetworkErrorTracking();
2633
- }
2634
- // Start batch timer
2635
- this.batchTimer = setInterval(() => {
2636
- this.flushEvents();
2637
- }, this.config.batchIntervalMs);
2638
- // Capture initial AppOpen event
2639
- this.captureEvent({
2640
- event_type: 'AppOpen',
2641
- timestamp: Date.now(),
2642
- properties: {
2643
- screen: this.currentScreen,
2644
- session_start: true
2645
- }
2646
- });
2647
- }
2648
- /**
2649
- * Stop capturing events
2650
- */
2651
- stop() {
2652
- console.log('[ATHENA] Stopping React Native event capture');
2653
- if (this.appStateSubscription) {
2654
- this.appStateSubscription.remove();
2655
- }
2656
- if (this.batchTimer) {
2657
- clearInterval(this.batchTimer);
2658
- }
2659
- // Flush any remaining events
2660
- this.flushEvents();
2661
- }
2662
- /**
2663
- * Setup app lifecycle tracking (Open, Background, Foreground, Close)
2664
- */
2665
- setupLifecycleTracking() {
2666
- this.appStateSubscription = AppState.addEventListener('change', nextAppState => {
2667
- if (nextAppState === 'active') {
2668
- this.captureEvent({
2669
- event_type: 'AppForeground',
2670
- timestamp: Date.now(),
2671
- properties: {
2672
- screen: this.currentScreen
2673
- }
2674
- });
2675
- } else if (nextAppState === 'background') {
2676
- this.captureEvent({
2677
- event_type: 'AppBackground',
2678
- timestamp: Date.now(),
2679
- properties: {
2680
- screen: this.currentScreen,
2681
- session_duration: Date.now() - this.sessionStartTime
2682
- }
2683
- });
2684
- } else if (nextAppState === 'inactive') {
2685
- this.captureEvent({
2686
- event_type: 'AppInactive',
2687
- timestamp: Date.now(),
2688
- properties: {
2689
- screen: this.currentScreen
2690
- }
2691
- });
2692
- }
2693
- });
2694
- }
2695
- /**
2696
- * Setup touch event tracking
2697
- */
2698
- setupTouchTracking() {
2699
- let touchStartTime = 0;
2700
- this.panResponder = PanResponder.create({
2701
- onStartShouldSetPanResponder: () => true,
2702
- onMoveShouldSetPanResponder: () => true,
2703
- onPanResponderGrant: (evt, gestureState) => {
2704
- touchStartTime = Date.now();
2705
- evt.nativeEvent.pageX;
2706
- evt.nativeEvent.pageY;
2707
- },
2708
- onPanResponderRelease: (evt, gestureState) => {
2709
- const touchDuration = Date.now() - touchStartTime;
2710
- const deltaX = Math.abs(gestureState.dx);
2711
- const deltaY = Math.abs(gestureState.dy);
2712
- // Detect gesture type
2713
- if (touchDuration > 500 && deltaX < 10 && deltaY < 10) {
2714
- // Long press
2715
- this.captureEvent({
2716
- event_type: 'LongPress',
2717
- timestamp: Date.now(),
2718
- properties: {
2719
- screen: this.currentScreen,
2720
- x: evt.nativeEvent.pageX,
2721
- y: evt.nativeEvent.pageY,
2722
- duration: touchDuration
2723
- }
2724
- });
2725
- } else if (deltaX > 50 || deltaY > 50) {
2726
- // Swipe
2727
- const direction = deltaX > deltaY ? gestureState.dx > 0 ? 'right' : 'left' : gestureState.dy > 0 ? 'down' : 'up';
2728
- this.captureEvent({
2729
- event_type: 'Swipe',
2730
- timestamp: Date.now(),
2731
- properties: {
2732
- screen: this.currentScreen,
2733
- direction,
2734
- distance: Math.sqrt(deltaX * deltaX + deltaY * deltaY)
2735
- }
2736
- });
2737
- } else {
2738
- // Tap
2739
- this.captureEvent({
2740
- event_type: 'Tap',
2741
- timestamp: Date.now(),
2742
- properties: {
2743
- screen: this.currentScreen,
2744
- x: evt.nativeEvent.pageX,
2745
- y: evt.nativeEvent.pageY,
2746
- duration: touchDuration
2747
- }
2748
- });
2749
- }
2750
- }
2751
- });
2752
- }
2753
- /**
2754
- * Setup network error tracking
2755
- */
2756
- setupNetworkErrorTracking() {
2757
- // Monkey-patch fetch to track network errors
2758
- const originalFetch = global.fetch;
2759
- global.fetch = async (...args) => {
2760
- const startTime = Date.now();
2761
- const url = typeof args[0] === 'string' ? args[0] : args[0].url;
2762
- try {
2763
- const response = await originalFetch(...args);
2764
- if (!response.ok) {
2765
- this.captureEvent({
2766
- event_type: 'NetworkError',
2767
- timestamp: Date.now(),
2768
- properties: {
2769
- screen: this.currentScreen,
2770
- url,
2771
- status: response.status,
2772
- statusText: response.statusText,
2773
- duration: Date.now() - startTime
2774
- }
2775
- });
2776
- }
2777
- return response;
2778
- } catch (error) {
2779
- this.captureEvent({
2780
- event_type: 'NetworkError',
2781
- timestamp: Date.now(),
2782
- properties: {
2783
- screen: this.currentScreen,
2784
- url,
2785
- error: error.message,
2786
- duration: Date.now() - startTime
2787
- }
2788
- });
2789
- throw error;
2790
- }
2791
- };
2792
- }
2793
- /**
2794
- * Manually track screen navigation
2795
- * Should be called by navigation library (React Navigation, etc.)
2796
- */
2797
- trackScreenView(screenName, params) {
2798
- this.currentScreen = screenName;
2799
- this.captureEvent({
2800
- event_type: 'ScreenView',
2801
- timestamp: Date.now(),
2802
- properties: {
2803
- screen: screenName,
2804
- params: params || {},
2805
- previous_screen: this.currentScreen
2806
- }
2807
- });
2808
- }
2809
- /**
2810
- * Manually track custom event
2811
- */
2812
- track(eventType, properties) {
2813
- this.captureEvent({
2814
- event_type: eventType,
2815
- timestamp: Date.now(),
2816
- properties: {
2817
- ...properties,
2818
- screen: this.currentScreen
2819
- }
2820
- });
2821
- }
2822
- /**
2823
- * Capture an event and add to batch
2824
- */
2825
- captureEvent(event) {
2826
- this.events.push(event);
2827
- // Flush immediately if batch size reached
2828
- if (this.events.length >= this.config.batchSize) {
2829
- this.flushEvents();
2830
- }
2831
- }
2832
- /**
2833
- * Flush accumulated events (to be sent to server)
2834
- */
2835
- flushEvents() {
2836
- if (this.events.length === 0) return;
2837
- const batch = [...this.events];
2838
- this.events = [];
2839
- // Emit events for tracker to send
2840
- this.onEventBatch?.(batch);
2841
- }
2842
- /**
2843
- * Get PanResponder for manual integration
2844
- * Usage: <View {...capture.getPanResponderProps()}>
2845
- */
2846
- getPanResponderProps() {
2847
- return this.panResponder?.panHandlers || {};
2848
- }
159
+ function getUserId() {
160
+ return trackerInstance?.getUserId() || null;
2849
161
  }
2850
-
2851
- /**
2852
- * @athena/tracker
2853
- *
2854
- * Behavioral analytics tracker with edge AI
2855
- */
2856
- // Version
2857
- const VERSION = '1.0.0';
2858
-
2859
- export { AthenaOTAWrapper, AthenaTracker, ReactNativeEventCapture, VERSION, AthenaTracker as default, detectInferenceMode, getPlatform, isBrowser, isReactNative };
162
+ // Default export
163
+ var index = {
164
+ initTracker,
165
+ getTracker,
166
+ identify,
167
+ track,
168
+ page,
169
+ reset,
170
+ getSessionId,
171
+ getUserId,
172
+ };
173
+
174
+ export { index as default, getSessionId, getTracker, getUserId, identify, initTracker, page, reset, track };
2860
175
  //# sourceMappingURL=index.esm.js.map