@moneybar.online/moneybar 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3065 @@
1
+ import { createClient } from '@supabase/supabase-js';
2
+ /**
3
+ * MoneyBar - The navbar of monetization
4
+ *
5
+ * Fix the 3 money-blocking stages that stop revenue:
6
+ * 1. Forced sign-ins before value → Value-first trials
7
+ * 2. Silent drop-offs → Exit feedback capture
8
+ * 3. Broken payment flows → Seamless Google Auth + payments
9
+ *
10
+ * Features:
11
+ * - Server-side usage tracking (incognito-proof)
12
+ * - Google OAuth authentication
13
+ * - Payment integration with DodoPayments
14
+ * - User feedback collection
15
+ * - Automatic UI management (paywall, auth, status)
16
+ * - User context for personalization
17
+ *
18
+ * @example Simple Usage (Recommended):
19
+ * ```javascript
20
+ * import { MoneyBar } from '@moneybar.online/moneybar';
21
+ *
22
+ * const moneyBar = new MoneyBar({
23
+ * appId: 'my-pdf-app',
24
+ * freeDownloadLimit: 3,
25
+ * supabase: { url: 'https://xyz.supabase.co', anonKey: 'anon_key' },
26
+ * payment: { productId: 'prod_xyz' }
27
+ * });
28
+ *
29
+ * // Single button - handles all monetization automatically
30
+ * moneyBar.attachToButton('#download-btn', (userContext) => {
31
+ * // Your action logic here - with user context for personalization
32
+ * if (userContext.isPremium) {
33
+ * generatePremiumPDF();
34
+ * } else {
35
+ * generateBasicPDF();
36
+ * }
37
+ * });
38
+ * ```
39
+ *
40
+ * @example Multiple Buttons:
41
+ * ```javascript
42
+ * moneyBar.attachToButtons({
43
+ * buttons: [
44
+ * {
45
+ * selector: '#free-btn',
46
+ * downloadCallback: (ctx) => downloadFreeTemplate(ctx),
47
+ * isPremium: false
48
+ * },
49
+ * {
50
+ * selector: '#premium-btn',
51
+ * downloadCallback: (ctx) => downloadPremiumTemplate(ctx),
52
+ * isPremium: true
53
+ * }
54
+ * ]
55
+ * });
56
+ * ```
57
+ */
58
+ export class MoneyBar {
59
+ mergeConfigs(config) {
60
+ // Try to get config from window.APP_CONFIG
61
+ const windowConfig = typeof window !== 'undefined' ? window.APP_CONFIG : null;
62
+ if (!config && !windowConfig) {
63
+ throw new Error('MoneyBar: No configuration provided. Either pass config to constructor or set window.APP_CONFIG');
64
+ }
65
+ // If no constructor config provided, use window config entirely
66
+ if (!config) {
67
+ return windowConfig;
68
+ }
69
+ // If no window config, use constructor config entirely
70
+ if (!windowConfig) {
71
+ return config;
72
+ }
73
+ // Merge configs: constructor config takes precedence over window config
74
+ return {
75
+ ...windowConfig,
76
+ ...config
77
+ };
78
+ }
79
+ constructor(config) {
80
+ this.currentUser = null;
81
+ this.userFingerprint = null;
82
+ this.eventListeners = new Map();
83
+ this.supabaseConnectionFailed = false;
84
+ this.paymentConnectionFailed = false;
85
+ this.cachedStatus = null;
86
+ this.statusCacheTime = 0;
87
+ this.STATUS_CACHE_DURATION = 5000; // 5 seconds cache
88
+ this.initializationPromise = null;
89
+ this.cachedPremiumStatus = null;
90
+ this.premiumStatusCacheTime = 0;
91
+ // Auto-load from window.APP_CONFIG if no config provided, or merge configs
92
+ this.config = this.mergeConfigs(config);
93
+ if (this.config.options?.debug) {
94
+ // console.log('🔍 DEBUG: MoneyBar constructor - full config:', JSON.stringify(config, null, 2));
95
+ // console.log('🔍 DEBUG: Email config present:', !!config.email);
96
+ }
97
+ this.validateConfig();
98
+ this.initializeSupabase();
99
+ this.initializePayment();
100
+ this.initializeFingerprint();
101
+ this.setupAuthListener();
102
+ this.checkPaymentStatus();
103
+ }
104
+ /**
105
+ * Main method to handle download attempts
106
+ * Call this from your download button's click handler
107
+ */
108
+ async handleDownload() {
109
+ try {
110
+ // Security check: if Supabase connection failed, disable downloads to prevent localStorage bypass
111
+ if (this.supabaseConnectionFailed) {
112
+ this.config.callbacks?.onError?.(new Error('Server connection required for download verification. Please check your configuration.'));
113
+ return;
114
+ }
115
+ // Security check: if payment configuration is invalid, disable downloads
116
+ if (this.config.payment && this.paymentConnectionFailed) {
117
+ this.config.callbacks?.onError?.(new Error('Payment configuration error. Please contact support.'));
118
+ return;
119
+ }
120
+ // Check if user is premium first (if authenticated)
121
+ if (this.currentUser) {
122
+ const isPremium = await this.checkPremiumStatus(this.currentUser.email);
123
+ if (isPremium) {
124
+ this.config.callbacks?.onPremiumDownload();
125
+ return;
126
+ }
127
+ }
128
+ // Check usage limits (works for both authenticated and anonymous users)
129
+ const status = await this.getDownloadStatus();
130
+ if (status.currentCount >= status.limit) {
131
+ // Limit reached - show paywall/limit message
132
+ this.config.callbacks?.onLimitReached(status.currentCount, status.limit);
133
+ return;
134
+ }
135
+ // Increment counter and proceed with action
136
+ await this.incrementDownloadCount();
137
+ this.config.callbacks?.onDownloadAllowed();
138
+ // Invalidate cache since count changed
139
+ this.cachedStatus = null;
140
+ // Check if limit reached after increment
141
+ const newStatus = await this.getDownloadStatus();
142
+ this.emit('countChanged', { count: newStatus.currentCount, limit: newStatus.limit });
143
+ if (newStatus.currentCount >= newStatus.limit) {
144
+ // Show paywall for next time
145
+ setTimeout(() => {
146
+ this.config.callbacks?.onLimitReached(newStatus.currentCount, newStatus.limit);
147
+ }, 100);
148
+ }
149
+ }
150
+ catch (error) {
151
+ this.handleError(error);
152
+ }
153
+ }
154
+ /**
155
+ * Get current download status for the user
156
+ */
157
+ async getDownloadStatus(forceRefresh = false) {
158
+ console.log(`🔍 [INIT] getDownloadStatus called (forceRefresh: ${forceRefresh}) at ${new Date().toISOString()}`);
159
+ // Check if we can use cached status
160
+ const cacheAge = this.cachedStatus ? Date.now() - this.statusCacheTime : -1;
161
+ const canUseCache = !forceRefresh && this.cachedStatus && cacheAge < this.STATUS_CACHE_DURATION;
162
+ if (canUseCache) {
163
+ console.log(`🔍 [INIT] Using cached status (age: ${cacheAge}ms)`);
164
+ return this.cachedStatus;
165
+ }
166
+ // If there's already an initialization in progress and it's not forced refresh, wait for it
167
+ if (!forceRefresh && this.initializationPromise) {
168
+ console.log(`🔍 [INIT] Waiting for existing initialization promise`);
169
+ return await this.initializationPromise;
170
+ }
171
+ console.log(`🔍 [INIT] Starting new status fetch (cache age: ${cacheAge}ms)`);
172
+ // Create the initialization promise
173
+ this.initializationPromise = this.fetchFreshStatus(forceRefresh);
174
+ try {
175
+ const result = await this.initializationPromise;
176
+ console.log(`🔍 [INIT] Status fetch completed successfully`);
177
+ return result;
178
+ }
179
+ finally {
180
+ // Clear the promise after completion
181
+ this.initializationPromise = null;
182
+ }
183
+ }
184
+ async fetchFreshStatus(forceRefresh) {
185
+ try {
186
+ let count = 0;
187
+ let isPremium = false;
188
+ // Only call API if we really need fresh data
189
+ if (forceRefresh || !this.cachedStatus) {
190
+ // Get download count only if we don't have it cached
191
+ count = await this.getDownloadCount();
192
+ }
193
+ else {
194
+ // Use cached count if available to avoid unnecessary API call
195
+ count = this.cachedStatus.currentCount;
196
+ }
197
+ // Check premium status only for authenticated users, and only when needed
198
+ if (this.currentUser) {
199
+ const premiumCacheValid = this.cachedPremiumStatus !== null && (Date.now() - this.premiumStatusCacheTime) < this.STATUS_CACHE_DURATION;
200
+ if (forceRefresh || !premiumCacheValid) {
201
+ console.log(`🔥 [SUPABASE API] About to call checkPremiumStatus from getDownloadStatus (forceRefresh: ${forceRefresh}, cacheValid: ${premiumCacheValid})`);
202
+ isPremium = await this.checkPremiumStatus(this.currentUser.email);
203
+ // Update cache
204
+ this.cachedPremiumStatus = isPremium;
205
+ this.premiumStatusCacheTime = Date.now();
206
+ }
207
+ else {
208
+ // Use cached premium status to avoid unnecessary API call
209
+ isPremium = this.cachedPremiumStatus; // We know it's not null because premiumCacheValid is true
210
+ console.log(`🔍 [CACHE] Using cached premium status from getDownloadStatus: ${isPremium}`);
211
+ }
212
+ }
213
+ else {
214
+ // Unauthenticated users cannot be premium
215
+ isPremium = false;
216
+ }
217
+ const status = {
218
+ currentCount: count,
219
+ limit: this.config.freeDownloadLimit,
220
+ isPremium,
221
+ isAuthenticated: !!this.currentUser,
222
+ remaining: Math.max(0, this.config.freeDownloadLimit - count)
223
+ };
224
+ // Cache the status
225
+ this.cachedStatus = status;
226
+ this.statusCacheTime = Date.now();
227
+ return status;
228
+ }
229
+ catch (error) {
230
+ this.handleError(error);
231
+ // Return safe defaults on error
232
+ const errorStatus = {
233
+ currentCount: 0,
234
+ limit: this.config.freeDownloadLimit,
235
+ isPremium: false,
236
+ isAuthenticated: false,
237
+ remaining: this.config.freeDownloadLimit
238
+ };
239
+ // Cache error status for short time to avoid repeated failures
240
+ this.cachedStatus = errorStatus;
241
+ this.statusCacheTime = Date.now();
242
+ return errorStatus;
243
+ }
244
+ }
245
+ /**
246
+ * Creates a UserContext object with current user information
247
+ */
248
+ async getUserContext() {
249
+ const status = await this.getDownloadStatus();
250
+ return {
251
+ isPremium: status.isPremium,
252
+ isAuthenticated: status.isAuthenticated,
253
+ email: this.currentUser?.email,
254
+ name: this.currentUser?.user_metadata?.full_name || this.currentUser?.user_metadata?.name,
255
+ currentCount: status.currentCount,
256
+ remaining: status.remaining,
257
+ limit: status.limit,
258
+ user: this.currentUser
259
+ };
260
+ }
261
+ /**
262
+ * Manually trigger Google sign-in
263
+ */
264
+ async signIn() {
265
+ try {
266
+ const { error } = await this.supabase.auth.signInWithOAuth({
267
+ provider: 'google',
268
+ options: {
269
+ redirectTo: `${window.location.origin}${window.location.pathname}`
270
+ }
271
+ });
272
+ if (error)
273
+ throw error;
274
+ }
275
+ catch (error) {
276
+ this.handleError(error);
277
+ }
278
+ }
279
+ /**
280
+ * Sign out current user
281
+ */
282
+ async signOut() {
283
+ try {
284
+ await this.supabase.auth.signOut();
285
+ this.currentUser = null;
286
+ this.emit('authChanged', { user: null, isPremium: false });
287
+ }
288
+ catch (error) {
289
+ this.handleError(error);
290
+ }
291
+ }
292
+ /**
293
+ * Create payment for premium upgrade
294
+ */
295
+ async createPayment() {
296
+ if (!this.currentUser) {
297
+ throw new Error('User must be signed in to create payment');
298
+ }
299
+ if (!this.config.payment) {
300
+ throw new Error('Payment configuration not provided');
301
+ }
302
+ const requestBody = {
303
+ email: this.currentUser.email,
304
+ product_id: this.config.payment.productId,
305
+ mode: this.config.payment.mode || 'test',
306
+ app_id: this.config.appId,
307
+ return_url: `${window.location.origin}${window.location.pathname}?payment=success`
308
+ };
309
+ console.log(`🔥 [SUPABASE API] createPayment called for email: ${this.currentUser.email} | Time: ${new Date().toISOString()}`);
310
+ try {
311
+ const response = await fetch(`${this.config.supabase.url}/functions/v1/create-payment`, {
312
+ method: 'POST',
313
+ headers: {
314
+ 'Content-Type': 'application/json',
315
+ 'Authorization': `Bearer ${this.config.supabase.anonKey}`
316
+ },
317
+ body: JSON.stringify(requestBody)
318
+ });
319
+ console.log(`🔥 [SUPABASE API] createPayment response: ${response.status}`);
320
+ if (this.config.options?.debug) {
321
+ //console.log('🔍 DEBUG: createPayment response status:', response.status);
322
+ }
323
+ if (!response.ok) {
324
+ const errorText = await response.text();
325
+ if (this.config.options?.debug) {
326
+ console.error('🔍 DEBUG: createPayment error response:', errorText);
327
+ }
328
+ let errorData;
329
+ try {
330
+ errorData = JSON.parse(errorText);
331
+ }
332
+ catch {
333
+ errorData = { error: errorText };
334
+ }
335
+ // Check if this is a product ID error (invalid config)
336
+ if (errorText.includes('404') || errorText.includes('could not be found')) {
337
+ this.paymentConnectionFailed = true;
338
+ if (this.config.options?.debug) {
339
+ console.warn('Invalid payment product ID detected, disabling downloads');
340
+ }
341
+ // Update UI to show disabled state
342
+ this.updateStatusDisplays();
343
+ }
344
+ throw new Error(errorData.error || 'Payment creation failed');
345
+ }
346
+ const result = await response.json();
347
+ if (this.config.options?.debug) {
348
+ //console.log('🔍 DEBUG: createPayment success response:', result);
349
+ }
350
+ return result;
351
+ }
352
+ catch (error) {
353
+ this.handleError(error);
354
+ return null;
355
+ }
356
+ }
357
+ /**
358
+ * Simplified API: Attach download limiting to a single button
359
+ * Handles all UI logic automatically (paywall, auth, payment flow)
360
+ */
361
+ attachToButton(selector, downloadCallback) {
362
+ //console.log('🎨 [THEME DEBUG] attachToButton called');
363
+ //console.log('🎨 [THEME DEBUG] Full config:', JSON.stringify(this.config, null, 2));
364
+ const button = document.querySelector(selector);
365
+ if (!button) {
366
+ throw new Error(`Button not found: ${selector}`);
367
+ }
368
+ // Store original button text (for potential future use)
369
+ // const originalText = button.textContent || 'Download';
370
+ // Create and inject UI elements
371
+ this.injectBaseStyles();
372
+ this.createTitleBar(); // Always create title bar first
373
+ this.createPaywallModal();
374
+ this.createSuccessModal();
375
+ this.createAuthUI();
376
+ this.createStatusDisplay();
377
+ // Set up button click handler
378
+ // Mark button as attached by LeadFast
379
+ button.setAttribute('data-leadfast-attached', 'true');
380
+ button.onclick = async (e) => {
381
+ e.preventDefault();
382
+ await this.handleButtonClick(downloadCallback);
383
+ };
384
+ // Update UI based on auth state
385
+ this.setupUIUpdates();
386
+ }
387
+ /**
388
+ * Simplified API: Attach download limiting to multiple buttons
389
+ * Each button can have different download callbacks and premium status
390
+ */
391
+ attachToButtons(config) {
392
+ this.injectBaseStyles();
393
+ this.createTitleBar(); // Always create title bar first
394
+ this.createPaywallModal();
395
+ this.createSuccessModal();
396
+ this.createAuthUI();
397
+ config.buttons.forEach(buttonConfig => {
398
+ const button = document.querySelector(buttonConfig.selector);
399
+ if (!button) {
400
+ console.warn(`Button not found: ${buttonConfig.selector}`);
401
+ return;
402
+ }
403
+ // Store original text for potential future use
404
+ // const originalText = button.textContent || 'Download';
405
+ // Set up click handler - all buttons use the same logic now
406
+ // Mark button as attached by LeadFast
407
+ button.setAttribute('data-leadfast-attached', 'true');
408
+ button.onclick = async (e) => {
409
+ e.preventDefault();
410
+ await this.handleButtonClick(buttonConfig.downloadCallback);
411
+ };
412
+ this.setupUIUpdates();
413
+ });
414
+ // Add global status display
415
+ this.createGlobalStatusDisplay();
416
+ }
417
+ async handleButtonClick(downloadCallback) {
418
+ // Prevent rapid clicks/race conditions
419
+ const button = document.querySelector('[data-leadfast-attached="true"]');
420
+ if (button && button.disabled) {
421
+ console.log('⚠️ Button click ignored - operation already in progress');
422
+ return;
423
+ }
424
+ if (button) {
425
+ button.disabled = true;
426
+ button.style.opacity = '0.6';
427
+ }
428
+ try {
429
+ await this.handleButtonClickInternal(downloadCallback);
430
+ }
431
+ finally {
432
+ // Re-enable button
433
+ if (button) {
434
+ button.disabled = false;
435
+ button.style.opacity = '1';
436
+ }
437
+ }
438
+ }
439
+ async handleButtonClickInternal(downloadCallback) {
440
+ // const clickTime = Date.now();
441
+ // console.log(`🕐 [TIMING] Button click started at: ${new Date(clickTime).toISOString()}`);
442
+ // Security check: if Supabase connection failed, disable downloads to prevent localStorage bypass
443
+ if (this.supabaseConnectionFailed) {
444
+ // console.log(`🕐 [TIMING] Connection failed check: ${Date.now() - clickTime}ms`);
445
+ this.showConnectionError();
446
+ return;
447
+ }
448
+ // Security check: if payment configuration is invalid, disable downloads
449
+ if (this.config.payment && this.paymentConnectionFailed) {
450
+ // console.log(`🕐 [TIMING] Payment config failed check: ${Date.now() - clickTime}ms`);
451
+ this.showPaymentConfigError();
452
+ return;
453
+ }
454
+ // Check cache status
455
+ const cacheValid = this.cachedStatus && (Date.now() - this.statusCacheTime) < this.STATUS_CACHE_DURATION;
456
+ // console.log(`🕐 [CACHE] Cache valid: ${cacheValid}, age: ${this.cachedStatus ? Date.now() - this.statusCacheTime : 'no cache'}ms`);
457
+ // console.log(`🕐 [CACHE] Cached status:`, this.cachedStatus);
458
+ // const statusStartTime = Date.now();
459
+ // Use cached status if available (since it's already displayed in title bar)
460
+ const status = cacheValid
461
+ ? this.cachedStatus
462
+ : await this.getDownloadStatus();
463
+ // console.log(`🕐 [TIMING] Status check completed: ${Date.now() - statusStartTime}ms (total: ${Date.now() - clickTime}ms)`);
464
+ // console.log(`🕐 [STATUS] Final status:`, status);
465
+ // Check if user is premium first (quick check from cached status)
466
+ if (status.isPremium) {
467
+ // console.log(`🕐 [TIMING] Premium user - callback executed: ${Date.now() - clickTime}ms`);
468
+ // Get user context for premium users too
469
+ const userContext = await this.getUserContext();
470
+ // Check if callback expects user context parameter
471
+ if (downloadCallback.length > 0) {
472
+ // Callback expects user context parameter
473
+ downloadCallback(userContext);
474
+ }
475
+ else {
476
+ // Legacy callback with no parameters
477
+ downloadCallback();
478
+ }
479
+ return;
480
+ }
481
+ // Quick limit check from cached status - show paywall immediately if needed
482
+ if (status.currentCount >= status.limit) {
483
+ // console.log(`🕐 [TIMING] Limit reached (${status.currentCount}/${status.limit}) - showing paywall: ${Date.now() - clickTime}ms`);
484
+ // Limit reached - show paywall instantly (no additional API calls)
485
+ // const paywallStartTime = Date.now();
486
+ this.showPaywallInstant(status);
487
+ // console.log(`🕐 [TIMING] Paywall shown: ${Date.now() - paywallStartTime}ms (total: ${Date.now() - clickTime}ms)`);
488
+ return;
489
+ }
490
+ // console.log(`🕐 [TIMING] Limit not reached (${status.currentCount}/${status.limit}) - proceeding with action`);
491
+ // Allow action and increment counter
492
+ // const incrementStartTime = Date.now();
493
+ // Execute user's function first - only increment count if it succeeds
494
+ try {
495
+ // Check if callback expects user context parameter
496
+ if (downloadCallback.length > 0) {
497
+ // Get user context BEFORE increment for callback
498
+ const userContext = await this.getUserContext();
499
+ // For non-premium users, simulate the increment so user context matches UI
500
+ if (!userContext.isPremium) {
501
+ userContext.currentCount += 1;
502
+ userContext.remaining = Math.max(0, userContext.limit - userContext.currentCount);
503
+ }
504
+ // Callback expects user context parameter
505
+ downloadCallback(userContext);
506
+ }
507
+ else {
508
+ // Legacy callback with no parameters
509
+ downloadCallback();
510
+ }
511
+ // Double-check limit before increment (race condition protection)
512
+ const freshStatus = await this.getDownloadStatus(true); // Force refresh
513
+ if (freshStatus.currentCount >= freshStatus.limit) {
514
+ console.warn(`⚠️ Limit reached during execution (${freshStatus.currentCount}/${freshStatus.limit}) - canceling increment`);
515
+ // User reached limit while their function was executing
516
+ alert('⚠️ You reached the limit while this action was processing. No attempt was counted.');
517
+ return;
518
+ }
519
+ // Only increment count after successful execution - with limit check
520
+ const newCount = await this.incrementDownloadCount();
521
+ // Double-check: if server returned count exceeding limit, something went wrong
522
+ if (newCount > this.config.freeDownloadLimit) {
523
+ console.error(`⚠️ Server returned count (${newCount}) exceeding limit (${this.config.freeDownloadLimit})`);
524
+ // Don't update UI with invalid state
525
+ return;
526
+ }
527
+ // console.log(`🕐 [TIMING] Count incremented: ${Date.now() - incrementStartTime}ms`);
528
+ // Show success message only if explicitly enabled in config
529
+ if (this.config.successMessage?.enabled === true) {
530
+ const title = this.config.successMessage?.title || 'Action Completed!';
531
+ const message = this.config.successMessage?.message || 'Your action completed successfully!';
532
+ this.showSuccess(title, message);
533
+ }
534
+ }
535
+ catch (error) {
536
+ console.error('User function failed:', error);
537
+ // Don't increment count on error - user shouldn't lose an attempt
538
+ alert('Action failed. Please check the console for details. No attempt was counted.');
539
+ return; // Exit early, don't update UI
540
+ }
541
+ // Update UI with fresh status (invalidate cache since count changed)
542
+ // console.log(`🕐 [CACHE] Invalidating cache due to count change (was: ${this.cachedStatus ? 'cached' : 'null'})`);
543
+ this.cachedStatus = null;
544
+ this.updateStatusDisplays();
545
+ // console.log(`🕐 [TIMING] Button click completed: ${Date.now() - clickTime}ms`);
546
+ }
547
+ injectBaseStyles() {
548
+ //console.log('🎨 [THEME DEBUG] injectBaseStyles called');
549
+ if (document.getElementById('lead-fast-styles')) {
550
+ //console.log('🎨 [THEME DEBUG] Styles already injected, skipping');
551
+ return;
552
+ }
553
+ // Inject DaisyUI CDN if theme is specified
554
+ if (this.config.theme?.name) {
555
+ //console.log('🎨 [THEME DEBUG] Theme specified, calling injectDaisyUI');
556
+ this.injectDaisyUI();
557
+ }
558
+ else {
559
+ //console.log('🎨 [THEME DEBUG] No theme specified in config');
560
+ }
561
+ const styles = document.createElement('style');
562
+ styles.id = 'lead-fast-styles';
563
+ const primaryColor = this.config.theme?.primaryColor || '#3182ce';
564
+ styles.textContent = `
565
+ /* User Profile Card - Top Right */
566
+ .lead-fast-profile {
567
+ position: fixed;
568
+ top: 20px;
569
+ left: 50%;
570
+ transform: translateX(-50%);
571
+ z-index: 1000;
572
+ font-family: system-ui, -apple-system, sans-serif;
573
+ width: 90%;
574
+ max-width: 1200px;
575
+ }
576
+
577
+ .lead-fast-title-bar {
578
+ background: rgba(250, 247, 245, 0.9) !important;
579
+ border: 1px solid rgba(231, 226, 223, 0.6) !important;
580
+ color: #291334 !important;
581
+ border-radius: 16px;
582
+ padding: 12px 24px;
583
+ box-shadow: 0 8px 32px rgb(0 0 0 / 0.1), 0 2px 8px rgb(0 0 0 / 0.05);
584
+ backdrop-filter: blur(20px);
585
+ display: flex;
586
+ align-items: center;
587
+ justify-content: space-between;
588
+ min-height: 60px;
589
+ font-family: system-ui, -apple-system, sans-serif;
590
+ }
591
+
592
+ /* Theme variations for floating title bar */
593
+ [data-theme="bumblebee"] .lead-fast-title-bar {
594
+ background: rgba(255, 248, 220, 0.9) !important;
595
+ border-color: rgba(254, 215, 170, 0.6) !important;
596
+ color: #1c1917 !important;
597
+ }
598
+
599
+ [data-theme="garden"] .lead-fast-title-bar {
600
+ background: rgba(240, 253, 244, 0.9) !important;
601
+ border-color: rgba(134, 239, 172, 0.6) !important;
602
+ color: #14532d !important;
603
+ }
604
+
605
+ [data-theme="emerald"] .lead-fast-title-bar {
606
+ background: rgba(236, 253, 245, 0.9) !important;
607
+ border-color: rgba(167, 243, 208, 0.6) !important;
608
+ color: #065f46 !important;
609
+ }
610
+
611
+ [data-theme="corporate"] .lead-fast-title-bar {
612
+ background: rgba(248, 250, 252, 0.9) !important;
613
+ border-color: rgba(226, 232, 240, 0.6) !important;
614
+ color: #1e293b !important;
615
+ }
616
+
617
+ [data-theme="dark"] .lead-fast-title-bar {
618
+ background: rgba(31, 41, 55, 0.9) !important;
619
+ border-color: rgba(55, 65, 81, 0.6) !important;
620
+ color: #f9fafb !important;
621
+ }
622
+
623
+ [data-theme="cyberpunk"] .lead-fast-title-bar {
624
+ background: rgba(0, 20, 36, 0.9) !important;
625
+ border-color: rgba(7, 89, 133, 0.6) !important;
626
+ color: #0ea5e9 !important;
627
+ box-shadow: 0 8px 32px rgba(14, 165, 233, 0.2), 0 2px 8px rgba(14, 165, 233, 0.1);
628
+ }
629
+
630
+ [data-theme="valentine"] .lead-fast-title-bar {
631
+ background: rgba(233, 30, 122, 0.15) !important;
632
+ border-color: rgba(233, 30, 122, 0.6) !important;
633
+ color: #831843 !important;
634
+ }
635
+
636
+ [data-theme="synthwave"] .lead-fast-title-bar {
637
+ background: rgba(32, 20, 64, 0.9) !important;
638
+ border-color: rgba(186, 85, 211, 0.6) !important;
639
+ color: #ff00ff !important;
640
+ box-shadow: 0 8px 32px rgba(255, 0, 255, 0.2), 0 2px 8px rgba(255, 0, 255, 0.1);
641
+ }
642
+
643
+ [data-theme="dracula"] .lead-fast-title-bar {
644
+ background: rgba(40, 42, 54, 0.9) !important;
645
+ border-color: rgba(98, 114, 164, 0.6) !important;
646
+ color: #f8f8f2 !important;
647
+ }
648
+
649
+ [data-theme="halloween"] .lead-fast-title-bar {
650
+ background: rgba(26, 26, 26, 0.9) !important;
651
+ border-color: rgba(255, 165, 0, 0.6) !important;
652
+ color: #ff6600 !important;
653
+ }
654
+
655
+ [data-theme="forest"] .lead-fast-title-bar {
656
+ background: rgba(23, 46, 23, 0.9) !important;
657
+ border-color: rgba(34, 197, 94, 0.6) !important;
658
+ color: #22c55e !important;
659
+ }
660
+
661
+ [data-theme="luxury"] .lead-fast-title-bar {
662
+ background: rgba(9, 9, 11, 0.9) !important;
663
+ border-color: rgba(212, 175, 55, 0.6) !important;
664
+ color: #d4af37 !important;
665
+ }
666
+
667
+ [data-theme="night"] .lead-fast-title-bar {
668
+ background: rgba(15, 23, 42, 0.9) !important;
669
+ border-color: rgba(30, 58, 138, 0.6) !important;
670
+ color: #60a5fa !important;
671
+ }
672
+
673
+ [data-theme="light"] .lead-fast-title-bar {
674
+ background: rgba(255, 255, 255, 0.9) !important;
675
+ border-color: rgba(229, 231, 235, 0.6) !important;
676
+ color: #1f2937 !important;
677
+ }
678
+
679
+ [data-theme="cupcake"] .lead-fast-title-bar {
680
+ background: rgba(250, 235, 215, 0.9) !important;
681
+ border-color: rgba(219, 185, 156, 0.6) !important;
682
+ color: #8b4513 !important;
683
+ }
684
+
685
+ [data-theme="retro"] .lead-fast-title-bar {
686
+ background: rgba(212, 165, 116, 0.9) !important;
687
+ border-color: rgba(185, 144, 102, 0.6) !important;
688
+ color: #5d4037 !important;
689
+ }
690
+
691
+ [data-theme="aqua"] .lead-fast-title-bar {
692
+ background: rgba(240, 253, 250, 0.9) !important;
693
+ border-color: rgba(125, 211, 252, 0.6) !important;
694
+ color: #155e75 !important;
695
+ }
696
+
697
+ [data-theme="lofi"] .lead-fast-title-bar {
698
+ background: rgba(248, 248, 248, 0.9) !important;
699
+ border-color: rgba(68, 68, 68, 0.6) !important;
700
+ color: #1a1a1a !important;
701
+ }
702
+
703
+ [data-theme="pastel"] .lead-fast-title-bar {
704
+ background: rgba(254, 251, 255, 0.9) !important;
705
+ border-color: rgba(209, 196, 233, 0.6) !important;
706
+ color: #7c3aed !important;
707
+ }
708
+
709
+ [data-theme="fantasy"] .lead-fast-title-bar {
710
+ background: rgba(255, 247, 237, 0.9) !important;
711
+ border-color: rgba(249, 168, 212, 0.6) !important;
712
+ color: #be185d !important;
713
+ }
714
+
715
+ [data-theme="wireframe"] .lead-fast-title-bar {
716
+ background: rgba(223, 223, 223, 0.9) !important;
717
+ border-color: rgba(0, 0, 0, 0.3) !important;
718
+ color: #000000 !important;
719
+ }
720
+
721
+ [data-theme="black"] .lead-fast-title-bar {
722
+ background: rgba(0, 0, 0, 0.9) !important;
723
+ border-color: rgba(55, 55, 55, 0.6) !important;
724
+ color: #ffffff !important;
725
+ }
726
+
727
+ [data-theme="cmyk"] .lead-fast-title-bar {
728
+ background: rgba(0, 255, 255, 0.9) !important;
729
+ border-color: rgba(255, 0, 255, 0.6) !important;
730
+ color: #000000 !important;
731
+ }
732
+
733
+ [data-theme="autumn"] .lead-fast-title-bar {
734
+ background: rgba(139, 69, 19, 0.9) !important;
735
+ border-color: rgba(255, 140, 0, 0.6) !important;
736
+ color: #ff8c00 !important;
737
+ }
738
+
739
+ [data-theme="business"] .lead-fast-title-bar {
740
+ background: rgba(29, 78, 216, 0.9) !important;
741
+ border-color: rgba(59, 130, 246, 0.6) !important;
742
+ color: #3b82f6 !important;
743
+ }
744
+
745
+ [data-theme="acid"] .lead-fast-title-bar {
746
+ background: rgba(255, 255, 0, 0.9) !important;
747
+ border-color: rgba(255, 0, 255, 0.6) !important;
748
+ color: #000000 !important;
749
+ }
750
+
751
+ [data-theme="lemonade"] .lead-fast-title-bar {
752
+ background: rgba(255, 255, 224, 0.9) !important;
753
+ border-color: rgba(34, 197, 94, 0.6) !important;
754
+ color: #15803d !important;
755
+ }
756
+
757
+ [data-theme="coffee"] .lead-fast-title-bar {
758
+ background: rgba(101, 67, 33, 0.9) !important;
759
+ border-color: rgba(160, 82, 45, 0.6) !important;
760
+ color: #d2b48c !important;
761
+ }
762
+
763
+ [data-theme="winter"] .lead-fast-title-bar {
764
+ background: rgba(248, 250, 252, 0.9) !important;
765
+ border-color: rgba(59, 130, 246, 0.6) !important;
766
+ color: #1e40af !important;
767
+ }
768
+
769
+ .lead-fast-title-section {
770
+ display: flex;
771
+ align-items: center;
772
+ gap: 16px;
773
+ }
774
+
775
+ .lead-fast-logo {
776
+ font-size: 20px;
777
+ font-weight: 700;
778
+ display: flex;
779
+ align-items: center;
780
+ gap: 8px;
781
+ color: inherit;
782
+ text-decoration: none;
783
+ }
784
+
785
+ .lead-fast-logo img {
786
+ width: 32px;
787
+ height: 32px;
788
+ border-radius: 6px;
789
+ }
790
+
791
+ .lead-fast-nav {
792
+ display: flex;
793
+ align-items: center;
794
+ gap: 32px;
795
+ margin-left: 24px;
796
+ }
797
+
798
+ .lead-fast-nav-link {
799
+ color: inherit;
800
+ text-decoration: none;
801
+ font-weight: 500;
802
+ font-size: 14px;
803
+ opacity: 0.8;
804
+ transition: all 0.2s;
805
+ }
806
+
807
+ .lead-fast-nav-link:hover {
808
+ opacity: 1;
809
+ text-decoration: none;
810
+ }
811
+
812
+ .lead-fast-user-section {
813
+ display: flex;
814
+ align-items: center;
815
+ gap: 12px;
816
+ }
817
+
818
+ .lead-fast-avatar {
819
+ width: 36px;
820
+ height: 36px;
821
+ border-radius: 50%;
822
+ background: linear-gradient(135deg, ${primaryColor}, #4f46e5);
823
+ display: flex;
824
+ align-items: center;
825
+ justify-content: center;
826
+ color: white;
827
+ font-weight: 600;
828
+ font-size: 14px;
829
+ }
830
+
831
+ .lead-fast-user-info {
832
+ display: flex;
833
+ flex-direction: column;
834
+ align-items: flex-start;
835
+ gap: 2px;
836
+ }
837
+
838
+ .lead-fast-user-email {
839
+ color: inherit !important;
840
+ font-size: 13px;
841
+ font-weight: 500;
842
+ line-height: 1;
843
+ }
844
+
845
+ .lead-fast-user-status {
846
+ display: flex;
847
+ align-items: center;
848
+ gap: 6px;
849
+ }
850
+
851
+ .lead-fast-badge {
852
+ padding: 2px 6px;
853
+ border-radius: 12px;
854
+ font-size: 10px;
855
+ font-weight: 600;
856
+ text-transform: uppercase;
857
+ letter-spacing: 0.025em;
858
+ line-height: 1;
859
+ }
860
+
861
+ .lead-fast-badge.premium {
862
+ background: #10b981 !important;
863
+ color: #ffffff !important;
864
+ }
865
+
866
+ .lead-fast-badge.free {
867
+ background: #65c3c8 !important;
868
+ color: #291334 !important;
869
+ }
870
+
871
+ [data-theme="dark"] .lead-fast-badge.premium {
872
+ background: #059669 !important;
873
+ color: #ffffff !important;
874
+ }
875
+
876
+ [data-theme="dark"] .lead-fast-badge.free {
877
+ background: #374151 !important;
878
+ color: #f9fafb !important;
879
+ }
880
+
881
+ .lead-fast-count {
882
+ font-size: 10px;
883
+ color: inherit !important;
884
+ opacity: 0.7;
885
+ line-height: 1;
886
+ }
887
+
888
+ .lead-fast-signout {
889
+ background: rgba(0, 0, 0, 0.1) !important;
890
+ border: none;
891
+ color: inherit !important;
892
+ cursor: pointer;
893
+ padding: 6px 12px;
894
+ border-radius: 8px;
895
+ transition: all 0.2s;
896
+ font-size: 11px;
897
+ font-weight: 500;
898
+ margin-left: 8px;
899
+ }
900
+
901
+ [data-theme="dark"] .lead-fast-signout {
902
+ background: rgba(255, 255, 255, 0.1) !important;
903
+ }
904
+
905
+ [data-theme="cyberpunk"] .lead-fast-signout {
906
+ background: rgba(14, 165, 233, 0.2) !important;
907
+ }
908
+
909
+ .lead-fast-signout:hover {
910
+ background: rgba(0, 0, 0, 0.2) !important;
911
+ transform: translateY(-1px);
912
+ }
913
+
914
+ [data-theme="dark"] .lead-fast-signout:hover {
915
+ background: rgba(255, 255, 255, 0.2) !important;
916
+ }
917
+
918
+ [data-theme="cyberpunk"] .lead-fast-signout:hover {
919
+ background: rgba(14, 165, 233, 0.3) !important;
920
+ }
921
+
922
+ .lead-fast-branding {
923
+ position: absolute;
924
+ bottom: -20px;
925
+ left: 24px;
926
+ font-size: 9px;
927
+ color: inherit !important;
928
+ opacity: 0.4;
929
+ font-weight: 500;
930
+ letter-spacing: 0.05em;
931
+ text-transform: lowercase;
932
+ background: rgba(255, 255, 255, 0.8);
933
+ padding: 2px 6px;
934
+ border-radius: 4px;
935
+ backdrop-filter: blur(8px);
936
+ }
937
+
938
+ [data-theme="dark"] .lead-fast-branding {
939
+ background: rgba(0, 0, 0, 0.6);
940
+ }
941
+
942
+ [data-theme="cyberpunk"] .lead-fast-branding {
943
+ background: rgba(0, 20, 36, 0.8);
944
+ }
945
+
946
+ /* Modal Theming */
947
+ .download-limiter-modal {
948
+ display: none;
949
+ position: fixed;
950
+ top: 0;
951
+ left: 0;
952
+ width: 100%;
953
+ height: 100%;
954
+ background: rgba(0,0,0,0.5);
955
+ z-index: 9999;
956
+ align-items: center;
957
+ justify-content: center;
958
+ }
959
+ .download-limiter-modal.show { display: flex; }
960
+
961
+ .download-limiter-content {
962
+ background: #faf7f5 !important;
963
+ color: #291334 !important;
964
+ padding: 2rem;
965
+ border-radius: 12px;
966
+ max-width: 400px;
967
+ text-align: center;
968
+ box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
969
+ border: 1px solid #e7e2df !important;
970
+ font-family: system-ui, -apple-system, sans-serif;
971
+ }
972
+
973
+ [data-theme="dark"] .download-limiter-content {
974
+ background: #1f2937 !important;
975
+ color: #f9fafb !important;
976
+ border-color: #374151 !important;
977
+ }
978
+
979
+ [data-theme="cyberpunk"] .download-limiter-content {
980
+ background: #001424 !important;
981
+ color: #0ea5e9 !important;
982
+ border-color: #075985 !important;
983
+ }
984
+
985
+ [data-theme="valentine"] .download-limiter-content {
986
+ background: rgba(233, 30, 122, 0.05) !important;
987
+ color: #831843 !important;
988
+ border-color: #e91e7a !important;
989
+ }
990
+
991
+ [data-theme="bumblebee"] .download-limiter-content {
992
+ background: rgba(255, 248, 220, 0.95) !important;
993
+ color: #1c1917 !important;
994
+ border-color: rgba(254, 215, 170, 0.8) !important;
995
+ }
996
+
997
+ [data-theme="garden"] .download-limiter-content {
998
+ background: rgba(240, 253, 244, 0.95) !important;
999
+ color: #14532d !important;
1000
+ border-color: rgba(134, 239, 172, 0.8) !important;
1001
+ }
1002
+
1003
+ [data-theme="emerald"] .download-limiter-content {
1004
+ background: rgba(236, 253, 245, 0.95) !important;
1005
+ color: #065f46 !important;
1006
+ border-color: rgba(167, 243, 208, 0.8) !important;
1007
+ }
1008
+
1009
+ [data-theme="corporate"] .download-limiter-content {
1010
+ background: rgba(248, 250, 252, 0.95) !important;
1011
+ color: #1e293b !important;
1012
+ border-color: rgba(226, 232, 240, 0.8) !important;
1013
+ }
1014
+
1015
+ [data-theme="forest"] .download-limiter-content {
1016
+ background: rgba(23, 46, 23, 0.95) !important;
1017
+ color: #22c55e !important;
1018
+ border-color: rgba(34, 197, 94, 0.8) !important;
1019
+ }
1020
+
1021
+ [data-theme="halloween"] .download-limiter-content {
1022
+ background: rgba(26, 26, 26, 0.95) !important;
1023
+ color: #ff6500 !important;
1024
+ border-color: rgba(255, 165, 0, 0.3) !important;
1025
+ }
1026
+
1027
+ [data-theme="synthwave"] .download-limiter-content {
1028
+ background: rgba(32, 20, 64, 0.95) !important;
1029
+ color: #ba55d3 !important;
1030
+ border-color: rgba(186, 85, 211, 0.3) !important;
1031
+ }
1032
+
1033
+ [data-theme="dracula"] .download-limiter-content {
1034
+ background: rgba(40, 42, 54, 0.95) !important;
1035
+ color: #f8f8f2 !important;
1036
+ border-color: rgba(98, 114, 164, 0.3) !important;
1037
+ }
1038
+
1039
+ [data-theme="luxury"] .download-limiter-content {
1040
+ background: rgba(9, 9, 11, 0.95) !important;
1041
+ color: #d4af37 !important;
1042
+ border-color: rgba(212, 175, 55, 0.3) !important;
1043
+ }
1044
+
1045
+ [data-theme="night"] .download-limiter-content {
1046
+ background: rgba(15, 23, 42, 0.95) !important;
1047
+ color: #1e40af !important;
1048
+ border-color: rgba(30, 58, 138, 0.3) !important;
1049
+ }
1050
+
1051
+ [data-theme="light"] .download-limiter-content {
1052
+ background: rgba(255, 255, 255, 0.95) !important;
1053
+ color: #1f2937 !important;
1054
+ border-color: rgba(229, 231, 235, 0.8) !important;
1055
+ }
1056
+
1057
+ [data-theme="cupcake"] .download-limiter-content {
1058
+ background: rgba(250, 235, 215, 0.95) !important;
1059
+ color: #8b4513 !important;
1060
+ border-color: rgba(219, 185, 156, 0.8) !important;
1061
+ }
1062
+
1063
+ [data-theme="retro"] .download-limiter-content {
1064
+ background: rgba(212, 165, 116, 0.95) !important;
1065
+ color: #5d4037 !important;
1066
+ border-color: rgba(185, 144, 102, 0.8) !important;
1067
+ }
1068
+
1069
+ [data-theme="aqua"] .download-limiter-content {
1070
+ background: rgba(240, 253, 250, 0.95) !important;
1071
+ color: #155e75 !important;
1072
+ border-color: rgba(125, 211, 252, 0.8) !important;
1073
+ }
1074
+
1075
+ [data-theme="lofi"] .download-limiter-content {
1076
+ background: rgba(248, 248, 248, 0.95) !important;
1077
+ color: #1a1a1a !important;
1078
+ border-color: rgba(68, 68, 68, 0.8) !important;
1079
+ }
1080
+
1081
+ [data-theme="pastel"] .download-limiter-content {
1082
+ background: rgba(254, 251, 255, 0.95) !important;
1083
+ color: #7c3aed !important;
1084
+ border-color: rgba(209, 196, 233, 0.8) !important;
1085
+ }
1086
+
1087
+ [data-theme="fantasy"] .download-limiter-content {
1088
+ background: rgba(255, 247, 237, 0.95) !important;
1089
+ color: #be185d !important;
1090
+ border-color: rgba(249, 168, 212, 0.8) !important;
1091
+ }
1092
+
1093
+ [data-theme="wireframe"] .download-limiter-content {
1094
+ background: rgba(255, 255, 255, 0.95) !important;
1095
+ color: #000000 !important;
1096
+ border-color: rgba(0, 0, 0, 0.3) !important;
1097
+ }
1098
+
1099
+ [data-theme="black"] .download-limiter-content {
1100
+ background: rgba(0, 0, 0, 0.95) !important;
1101
+ color: #ffffff !important;
1102
+ border-color: rgba(55, 55, 55, 0.8) !important;
1103
+ }
1104
+
1105
+ [data-theme="cmyk"] .download-limiter-content {
1106
+ background: rgba(0, 255, 255, 0.95) !important;
1107
+ color: #000000 !important;
1108
+ border-color: rgba(255, 0, 255, 0.8) !important;
1109
+ }
1110
+
1111
+ [data-theme="autumn"] .download-limiter-content {
1112
+ background: rgba(139, 69, 19, 0.95) !important;
1113
+ color: #ff8c00 !important;
1114
+ border-color: rgba(255, 140, 0, 0.8) !important;
1115
+ }
1116
+
1117
+ [data-theme="business"] .download-limiter-content {
1118
+ background: rgba(29, 78, 216, 0.95) !important;
1119
+ color: #3b82f6 !important;
1120
+ border-color: rgba(59, 130, 246, 0.8) !important;
1121
+ }
1122
+
1123
+ [data-theme="acid"] .download-limiter-content {
1124
+ background: rgba(255, 255, 0, 0.95) !important;
1125
+ color: #000000 !important;
1126
+ border-color: rgba(255, 0, 255, 0.8) !important;
1127
+ }
1128
+
1129
+ [data-theme="lemonade"] .download-limiter-content {
1130
+ background: rgba(255, 255, 224, 0.95) !important;
1131
+ color: #15803d !important;
1132
+ border-color: rgba(34, 197, 94, 0.8) !important;
1133
+ }
1134
+
1135
+ [data-theme="coffee"] .download-limiter-content {
1136
+ background: rgba(101, 67, 33, 0.95) !important;
1137
+ color: #d2b48c !important;
1138
+ border-color: rgba(160, 82, 45, 0.8) !important;
1139
+ }
1140
+
1141
+ [data-theme="winter"] .download-limiter-content {
1142
+ background: rgba(248, 250, 252, 0.95) !important;
1143
+ color: #1e40af !important;
1144
+ border-color: rgba(59, 130, 246, 0.8) !important;
1145
+ }
1146
+
1147
+ .download-limiter-content h2 {
1148
+ color: inherit !important;
1149
+ margin: 0 0 1rem 0;
1150
+ font-size: 1.5rem;
1151
+ font-weight: 600;
1152
+ }
1153
+ .download-limiter-content p {
1154
+ color: inherit !important;
1155
+ margin: 0 0 1.5rem 0;
1156
+ line-height: 1.6;
1157
+ }
1158
+ .download-limiter-signin-btn {
1159
+ display: inline-flex;
1160
+ align-items: center;
1161
+ gap: 8px;
1162
+ background: #65c3c8 !important;
1163
+ color: #291334 !important;
1164
+ border: none;
1165
+ padding: 12px 20px;
1166
+ border-radius: 8px;
1167
+ font-size: 14px;
1168
+ font-weight: 500;
1169
+ cursor: pointer;
1170
+ text-decoration: none;
1171
+ transition: all 0.2s;
1172
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
1173
+ }
1174
+
1175
+ [data-theme="dark"] .download-limiter-signin-btn {
1176
+ background: #3b82f6 !important;
1177
+ color: #ffffff !important;
1178
+ }
1179
+
1180
+ [data-theme="cyberpunk"] .download-limiter-signin-btn {
1181
+ background: #f59e0b !important;
1182
+ color: #000000 !important;
1183
+ }
1184
+
1185
+ [data-theme="valentine"] .download-limiter-signin-btn {
1186
+ background: #e91e7a !important;
1187
+ color: #ffffff !important;
1188
+ }
1189
+
1190
+ [data-theme="bumblebee"] .download-limiter-signin-btn {
1191
+ background: #fbbf24 !important;
1192
+ color: #1c1917 !important;
1193
+ }
1194
+
1195
+ [data-theme="garden"] .download-limiter-signin-btn {
1196
+ background: #22c55e !important;
1197
+ color: #ffffff !important;
1198
+ }
1199
+
1200
+ [data-theme="emerald"] .download-limiter-signin-btn {
1201
+ background: #10b981 !important;
1202
+ color: #ffffff !important;
1203
+ }
1204
+
1205
+ [data-theme="corporate"] .download-limiter-signin-btn {
1206
+ background: #3b82f6 !important;
1207
+ color: #ffffff !important;
1208
+ }
1209
+
1210
+ [data-theme="forest"] .download-limiter-signin-btn {
1211
+ background: #22c55e !important;
1212
+ color: #1a1a1a !important;
1213
+ }
1214
+
1215
+ [data-theme="halloween"] .download-limiter-signin-btn {
1216
+ background: #ff6500 !important;
1217
+ color: #1a1a1a !important;
1218
+ }
1219
+
1220
+ [data-theme="synthwave"] .download-limiter-signin-btn {
1221
+ background: #ba55d3 !important;
1222
+ color: #201040 !important;
1223
+ }
1224
+
1225
+ [data-theme="dracula"] .download-limiter-signin-btn {
1226
+ background: #8be9fd !important;
1227
+ color: #282a36 !important;
1228
+ }
1229
+
1230
+ [data-theme="luxury"] .download-limiter-signin-btn {
1231
+ background: #d4af37 !important;
1232
+ color: #09090b !important;
1233
+ }
1234
+
1235
+ [data-theme="night"] .download-limiter-signin-btn {
1236
+ background: #1e40af !important;
1237
+ color: #ffffff !important;
1238
+ }
1239
+
1240
+ [data-theme="light"] .download-limiter-signin-btn {
1241
+ background: #3b82f6 !important;
1242
+ color: #ffffff !important;
1243
+ }
1244
+
1245
+ [data-theme="cupcake"] .download-limiter-signin-btn {
1246
+ background: #8b4513 !important;
1247
+ color: #ffffff !important;
1248
+ }
1249
+
1250
+ [data-theme="retro"] .download-limiter-signin-btn {
1251
+ background: #d4a574 !important;
1252
+ color: #ffffff !important;
1253
+ }
1254
+
1255
+ [data-theme="aqua"] .download-limiter-signin-btn {
1256
+ background: #0891b2 !important;
1257
+ color: #ffffff !important;
1258
+ }
1259
+
1260
+ [data-theme="lofi"] .download-limiter-signin-btn {
1261
+ background: #1a1a1a !important;
1262
+ color: #ffffff !important;
1263
+ }
1264
+
1265
+ [data-theme="pastel"] .download-limiter-signin-btn {
1266
+ background: #7c3aed !important;
1267
+ color: #ffffff !important;
1268
+ }
1269
+
1270
+ [data-theme="fantasy"] .download-limiter-signin-btn {
1271
+ background: #be185d !important;
1272
+ color: #ffffff !important;
1273
+ }
1274
+
1275
+ [data-theme="wireframe"] .download-limiter-signin-btn {
1276
+ background: #dfdfdf !important;
1277
+ color: #000000 !important;
1278
+ border: 1px solid #000000 !important;
1279
+ }
1280
+
1281
+ [data-theme="black"] .download-limiter-signin-btn {
1282
+ background: #ffffff !important;
1283
+ color: #000000 !important;
1284
+ }
1285
+
1286
+ [data-theme="cmyk"] .download-limiter-signin-btn {
1287
+ background: #ff00ff !important;
1288
+ color: #000000 !important;
1289
+ }
1290
+
1291
+ [data-theme="autumn"] .download-limiter-signin-btn {
1292
+ background: #ff8c00 !important;
1293
+ color: #ffffff !important;
1294
+ }
1295
+
1296
+ [data-theme="business"] .download-limiter-signin-btn {
1297
+ background: #3b82f6 !important;
1298
+ color: #ffffff !important;
1299
+ }
1300
+
1301
+ [data-theme="acid"] .download-limiter-signin-btn {
1302
+ background: #ff00ff !important;
1303
+ color: #000000 !important;
1304
+ }
1305
+
1306
+ [data-theme="lemonade"] .download-limiter-signin-btn {
1307
+ background: #22c55e !important;
1308
+ color: #ffffff !important;
1309
+ }
1310
+
1311
+ [data-theme="coffee"] .download-limiter-signin-btn {
1312
+ background: #a0522d !important;
1313
+ color: #ffffff !important;
1314
+ }
1315
+
1316
+ [data-theme="winter"] .download-limiter-signin-btn {
1317
+ background: #3b82f6 !important;
1318
+ color: #ffffff !important;
1319
+ }
1320
+
1321
+ .download-limiter-signin-btn:hover {
1322
+ opacity: 0.9;
1323
+ transform: translateY(-1px);
1324
+ box-shadow: 0 4px 8px rgba(0,0,0,0.15);
1325
+ }
1326
+
1327
+ /* Upgrade Button Styles for All Themes */
1328
+ [data-theme="dark"] .upgrade-btn {
1329
+ background: #3b82f6 !important;
1330
+ color: #ffffff !important;
1331
+ }
1332
+
1333
+ [data-theme="cyberpunk"] .upgrade-btn {
1334
+ background: #ff073a !important;
1335
+ color: #ffffff !important;
1336
+ }
1337
+
1338
+ [data-theme="valentine"] .upgrade-btn {
1339
+ background: #e91e7a !important;
1340
+ color: #ffffff !important;
1341
+ }
1342
+
1343
+ [data-theme="bumblebee"] .upgrade-btn {
1344
+ background: #f59e0b !important;
1345
+ color: #ffffff !important;
1346
+ }
1347
+
1348
+ [data-theme="garden"] .upgrade-btn {
1349
+ background: #10b981 !important;
1350
+ color: #ffffff !important;
1351
+ }
1352
+
1353
+ [data-theme="emerald"] .upgrade-btn {
1354
+ background: #10b981 !important;
1355
+ color: #ffffff !important;
1356
+ }
1357
+
1358
+ [data-theme="corporate"] .upgrade-btn {
1359
+ background: #3b82f6 !important;
1360
+ color: #ffffff !important;
1361
+ }
1362
+
1363
+ [data-theme="forest"] .upgrade-btn {
1364
+ background: #10b981 !important;
1365
+ color: #ffffff !important;
1366
+ }
1367
+
1368
+ [data-theme="halloween"] .upgrade-btn {
1369
+ background: #ff7b00 !important;
1370
+ color: #000000 !important;
1371
+ }
1372
+
1373
+ [data-theme="synthwave"] .upgrade-btn {
1374
+ background: #e879f9 !important;
1375
+ color: #ffffff !important;
1376
+ }
1377
+
1378
+ [data-theme="dracula"] .upgrade-btn {
1379
+ background: #bd93f9 !important;
1380
+ color: #ffffff !important;
1381
+ }
1382
+
1383
+ [data-theme="luxury"] .upgrade-btn {
1384
+ background: #d4af37 !important;
1385
+ color: #000000 !important;
1386
+ }
1387
+
1388
+ [data-theme="night"] .upgrade-btn {
1389
+ background: #38bdf8 !important;
1390
+ color: #ffffff !important;
1391
+ }
1392
+
1393
+ [data-theme="light"] .upgrade-btn {
1394
+ background: #3b82f6 !important;
1395
+ color: #ffffff !important;
1396
+ }
1397
+
1398
+ [data-theme="cupcake"] .upgrade-btn {
1399
+ background: #f472b6 !important;
1400
+ color: #ffffff !important;
1401
+ }
1402
+
1403
+ [data-theme="retro"] .upgrade-btn {
1404
+ background: #d4a574 !important;
1405
+ color: #ffffff !important;
1406
+ }
1407
+
1408
+ [data-theme="aqua"] .upgrade-btn {
1409
+ background: #06b6d4 !important;
1410
+ color: #ffffff !important;
1411
+ }
1412
+
1413
+ [data-theme="lofi"] .upgrade-btn {
1414
+ background: #a3a3a3 !important;
1415
+ color: #000000 !important;
1416
+ }
1417
+
1418
+ [data-theme="pastel"] .upgrade-btn {
1419
+ background: #a78bfa !important;
1420
+ color: #ffffff !important;
1421
+ }
1422
+
1423
+ [data-theme="fantasy"] .upgrade-btn {
1424
+ background: #f472b6 !important;
1425
+ color: #ffffff !important;
1426
+ }
1427
+
1428
+ [data-theme="wireframe"] .upgrade-btn {
1429
+ background: #dfdfdf !important;
1430
+ color: #000000 !important;
1431
+ border: 1px solid #000000 !important;
1432
+ }
1433
+
1434
+ [data-theme="black"] .upgrade-btn {
1435
+ background: #ffffff !important;
1436
+ color: #000000 !important;
1437
+ }
1438
+
1439
+ [data-theme="cmyk"] .upgrade-btn {
1440
+ background: #0891b2 !important;
1441
+ color: #ffffff !important;
1442
+ }
1443
+
1444
+ [data-theme="autumn"] .upgrade-btn {
1445
+ background: #d97706 !important;
1446
+ color: #ffffff !important;
1447
+ }
1448
+
1449
+ [data-theme="business"] .upgrade-btn {
1450
+ background: #3b82f6 !important;
1451
+ color: #ffffff !important;
1452
+ }
1453
+
1454
+ [data-theme="acid"] .upgrade-btn {
1455
+ background: #84cc16 !important;
1456
+ color: #000000 !important;
1457
+ }
1458
+
1459
+ [data-theme="lemonade"] .upgrade-btn {
1460
+ background: #22c55e !important;
1461
+ color: #ffffff !important;
1462
+ }
1463
+
1464
+ [data-theme="coffee"] .upgrade-btn {
1465
+ background: #a0522d !important;
1466
+ color: #ffffff !important;
1467
+ }
1468
+
1469
+ [data-theme="winter"] .upgrade-btn {
1470
+ background: #3b82f6 !important;
1471
+ color: #ffffff !important;
1472
+ }
1473
+
1474
+ /* Cancel Button Styles for All Themes */
1475
+ [data-theme="dark"] .cancel-btn {
1476
+ background: #4b5563 !important;
1477
+ color: #ffffff !important;
1478
+ }
1479
+
1480
+ [data-theme="cyberpunk"] .cancel-btn {
1481
+ background: #7e22ce !important;
1482
+ color: #ffffff !important;
1483
+ }
1484
+
1485
+ [data-theme="valentine"] .cancel-btn {
1486
+ background: #c11560 !important;
1487
+ color: #ffffff !important;
1488
+ }
1489
+
1490
+ [data-theme="bumblebee"] .cancel-btn {
1491
+ background: #d97706 !important;
1492
+ color: #ffffff !important;
1493
+ }
1494
+
1495
+ [data-theme="garden"] .cancel-btn {
1496
+ background: #059669 !important;
1497
+ color: #ffffff !important;
1498
+ }
1499
+
1500
+ [data-theme="emerald"] .cancel-btn {
1501
+ background: #059669 !important;
1502
+ color: #ffffff !important;
1503
+ }
1504
+
1505
+ [data-theme="corporate"] .cancel-btn {
1506
+ background: #6b7280 !important;
1507
+ color: #ffffff !important;
1508
+ }
1509
+
1510
+ [data-theme="forest"] .cancel-btn {
1511
+ background: #059669 !important;
1512
+ color: #ffffff !important;
1513
+ }
1514
+
1515
+ [data-theme="halloween"] .cancel-btn {
1516
+ background: #7c3aed !important;
1517
+ color: #ffffff !important;
1518
+ }
1519
+
1520
+ [data-theme="synthwave"] .cancel-btn {
1521
+ background: #7e22ce !important;
1522
+ color: #ffffff !important;
1523
+ }
1524
+
1525
+ [data-theme="dracula"] .cancel-btn {
1526
+ background: #6272a4 !important;
1527
+ color: #ffffff !important;
1528
+ }
1529
+
1530
+ [data-theme="luxury"] .cancel-btn {
1531
+ background: #8b5cf6 !important;
1532
+ color: #ffffff !important;
1533
+ }
1534
+
1535
+ [data-theme="night"] .cancel-btn {
1536
+ background: #0284c7 !important;
1537
+ color: #ffffff !important;
1538
+ }
1539
+
1540
+ [data-theme="light"] .cancel-btn {
1541
+ background: #6b7280 !important;
1542
+ color: #ffffff !important;
1543
+ }
1544
+
1545
+ [data-theme="cupcake"] .cancel-btn {
1546
+ background: #ec4899 !important;
1547
+ color: #ffffff !important;
1548
+ }
1549
+
1550
+ [data-theme="retro"] .cancel-btn {
1551
+ background: #b8925c !important;
1552
+ color: #ffffff !important;
1553
+ }
1554
+
1555
+ [data-theme="aqua"] .cancel-btn {
1556
+ background: #0891b2 !important;
1557
+ color: #ffffff !important;
1558
+ }
1559
+
1560
+ [data-theme="lofi"] .cancel-btn {
1561
+ background: #6b7280 !important;
1562
+ color: #ffffff !important;
1563
+ }
1564
+
1565
+ [data-theme="pastel"] .cancel-btn {
1566
+ background: #8b5cf6 !important;
1567
+ color: #ffffff !important;
1568
+ }
1569
+
1570
+ [data-theme="fantasy"] .cancel-btn {
1571
+ background: #ec4899 !important;
1572
+ color: #ffffff !important;
1573
+ }
1574
+
1575
+ [data-theme="wireframe"] .cancel-btn {
1576
+ background: #f5f5f5 !important;
1577
+ color: #000000 !important;
1578
+ border: 1px solid #000000 !important;
1579
+ }
1580
+
1581
+ [data-theme="black"] .cancel-btn {
1582
+ background: #6b7280 !important;
1583
+ color: #ffffff !important;
1584
+ }
1585
+
1586
+ [data-theme="cmyk"] .cancel-btn {
1587
+ background: #0369a1 !important;
1588
+ color: #ffffff !important;
1589
+ }
1590
+
1591
+ [data-theme="autumn"] .cancel-btn {
1592
+ background: #c2410c !important;
1593
+ color: #ffffff !important;
1594
+ }
1595
+
1596
+ [data-theme="business"] .cancel-btn {
1597
+ background: #6b7280 !important;
1598
+ color: #ffffff !important;
1599
+ }
1600
+
1601
+ [data-theme="acid"] .cancel-btn {
1602
+ background: #65a30d !important;
1603
+ color: #ffffff !important;
1604
+ }
1605
+
1606
+ [data-theme="lemonade"] .cancel-btn {
1607
+ background: #16a34a !important;
1608
+ color: #ffffff !important;
1609
+ }
1610
+
1611
+ [data-theme="coffee"] .cancel-btn {
1612
+ background: #8b4513 !important;
1613
+ color: #ffffff !important;
1614
+ }
1615
+
1616
+ [data-theme="winter"] .cancel-btn {
1617
+ background: #1e40af !important;
1618
+ color: #ffffff !important;
1619
+ }
1620
+
1621
+ /* Success Button Styles for All Themes */
1622
+ [data-theme="dark"] .success-btn {
1623
+ background: #10b981 !important;
1624
+ color: #ffffff !important;
1625
+ }
1626
+
1627
+ [data-theme="cyberpunk"] .success-btn {
1628
+ background: #00ff41 !important;
1629
+ color: #000000 !important;
1630
+ }
1631
+
1632
+ [data-theme="valentine"] .success-btn {
1633
+ background: #e91e7a !important;
1634
+ color: #ffffff !important;
1635
+ }
1636
+
1637
+ [data-theme="bumblebee"] .success-btn {
1638
+ background: #f59e0b !important;
1639
+ color: #ffffff !important;
1640
+ }
1641
+
1642
+ [data-theme="garden"] .success-btn {
1643
+ background: #10b981 !important;
1644
+ color: #ffffff !important;
1645
+ }
1646
+
1647
+ [data-theme="emerald"] .success-btn {
1648
+ background: #10b981 !important;
1649
+ color: #ffffff !important;
1650
+ }
1651
+
1652
+ [data-theme="corporate"] .success-btn {
1653
+ background: #10b981 !important;
1654
+ color: #ffffff !important;
1655
+ }
1656
+
1657
+ [data-theme="forest"] .success-btn {
1658
+ background: #10b981 !important;
1659
+ color: #ffffff !important;
1660
+ }
1661
+
1662
+ [data-theme="halloween"] .success-btn {
1663
+ background: #ff7b00 !important;
1664
+ color: #000000 !important;
1665
+ }
1666
+
1667
+ [data-theme="synthwave"] .success-btn {
1668
+ background: #00ff41 !important;
1669
+ color: #000000 !important;
1670
+ }
1671
+
1672
+ [data-theme="dracula"] .success-btn {
1673
+ background: #50fa7b !important;
1674
+ color: #000000 !important;
1675
+ }
1676
+
1677
+ [data-theme="luxury"] .success-btn {
1678
+ background: #d4af37 !important;
1679
+ color: #000000 !important;
1680
+ }
1681
+
1682
+ [data-theme="night"] .success-btn {
1683
+ background: #22d3ee !important;
1684
+ color: #ffffff !important;
1685
+ }
1686
+
1687
+ [data-theme="light"] .success-btn {
1688
+ background: #10b981 !important;
1689
+ color: #ffffff !important;
1690
+ }
1691
+
1692
+ [data-theme="cupcake"] .success-btn {
1693
+ background: #f472b6 !important;
1694
+ color: #ffffff !important;
1695
+ }
1696
+
1697
+ [data-theme="retro"] .success-btn {
1698
+ background: #d4a574 !important;
1699
+ color: #ffffff !important;
1700
+ }
1701
+
1702
+ [data-theme="aqua"] .success-btn {
1703
+ background: #06b6d4 !important;
1704
+ color: #ffffff !important;
1705
+ }
1706
+
1707
+ [data-theme="lofi"] .success-btn {
1708
+ background: #10b981 !important;
1709
+ color: #ffffff !important;
1710
+ }
1711
+
1712
+ [data-theme="pastel"] .success-btn {
1713
+ background: #34d399 !important;
1714
+ color: #ffffff !important;
1715
+ }
1716
+
1717
+ [data-theme="fantasy"] .success-btn {
1718
+ background: #f472b6 !important;
1719
+ color: #ffffff !important;
1720
+ }
1721
+
1722
+ [data-theme="wireframe"] .success-btn {
1723
+ background: #dfdfdf !important;
1724
+ color: #000000 !important;
1725
+ border: 1px solid #000000 !important;
1726
+ }
1727
+
1728
+ [data-theme="black"] .success-btn {
1729
+ background: #10b981 !important;
1730
+ color: #ffffff !important;
1731
+ }
1732
+
1733
+ [data-theme="cmyk"] .success-btn {
1734
+ background: #06b6d4 !important;
1735
+ color: #ffffff !important;
1736
+ }
1737
+
1738
+ [data-theme="autumn"] .success-btn {
1739
+ background: #d97706 !important;
1740
+ color: #ffffff !important;
1741
+ }
1742
+
1743
+ [data-theme="business"] .success-btn {
1744
+ background: #10b981 !important;
1745
+ color: #ffffff !important;
1746
+ }
1747
+
1748
+ [data-theme="acid"] .success-btn {
1749
+ background: #84cc16 !important;
1750
+ color: #000000 !important;
1751
+ }
1752
+
1753
+ [data-theme="lemonade"] .success-btn {
1754
+ background: #22c55e !important;
1755
+ color: #ffffff !important;
1756
+ }
1757
+
1758
+ [data-theme="coffee"] .success-btn {
1759
+ background: #a0522d !important;
1760
+ color: #ffffff !important;
1761
+ }
1762
+
1763
+ [data-theme="winter"] .success-btn {
1764
+ background: #3b82f6 !important;
1765
+ color: #ffffff !important;
1766
+ }
1767
+ .download-limiter-signout-btn {
1768
+ background: #dc3545;
1769
+ color: white;
1770
+ border: none;
1771
+ padding: 6px 12px;
1772
+ border-radius: 4px;
1773
+ font-size: 12px;
1774
+ cursor: pointer;
1775
+ margin-left: 8px;
1776
+ }
1777
+ .download-limiter-premium-badge {
1778
+ background: linear-gradient(45deg, #f39c12, #e74c3c);
1779
+ color: white;
1780
+ padding: 2px 6px;
1781
+ border-radius: 3px;
1782
+ font-size: 10px;
1783
+ margin-left: 8px;
1784
+ font-weight: bold;
1785
+ }
1786
+ .download-limiter-btn-premium {
1787
+ opacity: 0.7;
1788
+ }
1789
+ .download-limiter-success-modal {
1790
+ display: none;
1791
+ position: fixed;
1792
+ top: 0;
1793
+ left: 0;
1794
+ width: 100%;
1795
+ height: 100%;
1796
+ background: rgba(0,0,0,0.5);
1797
+ z-index: 10000;
1798
+ align-items: center;
1799
+ justify-content: center;
1800
+ }
1801
+ .download-limiter-success-modal.show { display: flex; }
1802
+ .download-limiter-success-content {
1803
+ background: white;
1804
+ padding: 2rem;
1805
+ border-radius: 8px;
1806
+ max-width: 400px;
1807
+ text-align: center;
1808
+ box-shadow: 0 4px 20px rgba(0,0,0,0.15);
1809
+ border-left: 4px solid #38a169;
1810
+ }
1811
+
1812
+ /* Single upgrade flow styles */
1813
+ .single-upgrade-container {
1814
+ margin: 20px 0;
1815
+ text-align: center;
1816
+ }
1817
+
1818
+ .single-upgrade-content .upgrade-btn {
1819
+ background: linear-gradient(135deg, #059669, #0d9488) !important;
1820
+ color: white !important;
1821
+ border: none !important;
1822
+ padding: 16px 32px !important;
1823
+ border-radius: 12px !important;
1824
+ font-size: 18px !important;
1825
+ font-weight: 600 !important;
1826
+ cursor: pointer !important;
1827
+ transition: all 0.3s ease !important;
1828
+ box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3) !important;
1829
+ margin-bottom: 16px !important;
1830
+ min-width: 200px !important;
1831
+ }
1832
+
1833
+ .single-upgrade-content .upgrade-btn:hover {
1834
+ background: linear-gradient(135deg, #047857, #0f766e) !important;
1835
+ transform: translateY(-2px) !important;
1836
+ box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4) !important;
1837
+ }
1838
+
1839
+ .single-upgrade-content .upgrade-description {
1840
+ font-size: 14px !important;
1841
+ color: #6b7280 !important;
1842
+ margin: 12px 0 0 0 !important;
1843
+ line-height: 1.5 !important;
1844
+ max-width: 300px !important;
1845
+ margin-left: auto !important;
1846
+ margin-right: auto !important;
1847
+ }
1848
+
1849
+ /* Anonymous user usage count styles */
1850
+ .lead-fast-anonymous-status {
1851
+ display: flex;
1852
+ align-items: center;
1853
+ gap: 12px;
1854
+ }
1855
+
1856
+ .lead-fast-anonymous-status .lead-fast-count {
1857
+ background: rgba(59, 130, 246, 0.1);
1858
+ color: #1d4ed8;
1859
+ padding: 6px 12px;
1860
+ border-radius: 8px;
1861
+ font-size: 14px;
1862
+ font-weight: 500;
1863
+ border: 1px solid rgba(59, 130, 246, 0.2);
1864
+ }
1865
+
1866
+ /* Success button theming */
1867
+ .download-limiter-btn.success-btn {
1868
+ background: #059669 !important;
1869
+ color: white !important;
1870
+ border: none !important;
1871
+ padding: 12px 24px !important;
1872
+ border-radius: 8px !important;
1873
+ cursor: pointer !important;
1874
+ margin-top: 20px !important;
1875
+ font-size: 16px !important;
1876
+ font-weight: 500 !important;
1877
+ transition: all 0.2s ease !important;
1878
+ }
1879
+
1880
+ .download-limiter-btn.success-btn:hover {
1881
+ background: #047857 !important;
1882
+ transform: translateY(-1px) !important;
1883
+ }
1884
+
1885
+ /* Theme-specific success button colors */
1886
+ [data-theme="cyberpunk"] .download-limiter-btn.success-btn {
1887
+ background: #0ea5e9 !important;
1888
+ box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3) !important;
1889
+ }
1890
+
1891
+ [data-theme="cyberpunk"] .download-limiter-btn.success-btn:hover {
1892
+ background: #0284c7 !important;
1893
+ }
1894
+
1895
+ [data-theme="valentine"] .download-limiter-btn.success-btn {
1896
+ background: #be185d !important;
1897
+ }
1898
+
1899
+ [data-theme="valentine"] .download-limiter-btn.success-btn:hover {
1900
+ background: #9d174d !important;
1901
+ }
1902
+
1903
+ [data-theme="bumblebee"] .download-limiter-btn.success-btn {
1904
+ background: #f59e0b !important;
1905
+ }
1906
+
1907
+ [data-theme="bumblebee"] .download-limiter-btn.success-btn:hover {
1908
+ background: #d97706 !important;
1909
+ }
1910
+
1911
+ [data-theme="garden"] .download-limiter-btn.success-btn {
1912
+ background: #16a34a !important;
1913
+ }
1914
+
1915
+ [data-theme="garden"] .download-limiter-btn.success-btn:hover {
1916
+ background: #15803d !important;
1917
+ }
1918
+
1919
+ /* Google Sign-in button theming */
1920
+ .download-limiter-btn.google-signin-btn {
1921
+ background: #4285f4 !important;
1922
+ color: white !important;
1923
+ border: none !important;
1924
+ padding: 12px 24px !important;
1925
+ border-radius: 8px !important;
1926
+ cursor: pointer !important;
1927
+ margin-right: 10px !important;
1928
+ display: inline-flex !important;
1929
+ align-items: center !important;
1930
+ gap: 8px !important;
1931
+ font-size: 14px !important;
1932
+ font-weight: 500 !important;
1933
+ transition: all 0.2s ease !important;
1934
+ }
1935
+
1936
+ .download-limiter-btn.google-signin-btn:hover {
1937
+ background: #3367d6 !important;
1938
+ transform: translateY(-1px) !important;
1939
+ }
1940
+
1941
+ /* Upgrade button theming */
1942
+ .download-limiter-btn.upgrade-btn {
1943
+ background: #059669 !important;
1944
+ color: white !important;
1945
+ border: none !important;
1946
+ padding: 12px 24px !important;
1947
+ border-radius: 8px !important;
1948
+ cursor: pointer !important;
1949
+ margin-right: 10px !important;
1950
+ font-size: 16px !important;
1951
+ font-weight: 500 !important;
1952
+ transition: all 0.2s ease !important;
1953
+ }
1954
+
1955
+ .download-limiter-btn.upgrade-btn:hover {
1956
+ background: #047857 !important;
1957
+ transform: translateY(-1px) !important;
1958
+ }
1959
+
1960
+ /* Theme-specific button colors */
1961
+ [data-theme="cyberpunk"] .download-limiter-btn.upgrade-btn {
1962
+ background: #0ea5e9 !important;
1963
+ box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3) !important;
1964
+ }
1965
+
1966
+ [data-theme="valentine"] .download-limiter-btn.upgrade-btn {
1967
+ background: #be185d !important;
1968
+ }
1969
+
1970
+ [data-theme="bumblebee"] .download-limiter-btn.upgrade-btn {
1971
+ background: #f59e0b !important;
1972
+ }
1973
+
1974
+ [data-theme="garden"] .download-limiter-btn.upgrade-btn {
1975
+ background: #16a34a !important;
1976
+ }
1977
+
1978
+ /* Cancel button container and styling - positioned at very bottom */
1979
+ .download-limiter-cancel-container {
1980
+ margin-top: 30px !important;
1981
+ padding-top: 20px !important;
1982
+ border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
1983
+ text-align: center !important;
1984
+ position: relative !important;
1985
+ bottom: 0 !important;
1986
+ }
1987
+
1988
+ .download-limiter-btn.cancel-btn {
1989
+ background: transparent !important;
1990
+ color: #6b7280 !important;
1991
+ border: none !important;
1992
+ padding: 8px 16px !important;
1993
+ border-radius: 6px !important;
1994
+ cursor: pointer !important;
1995
+ font-size: 13px !important;
1996
+ font-weight: 400 !important;
1997
+ transition: all 0.2s ease !important;
1998
+ text-decoration: underline !important;
1999
+ margin: 0 auto !important;
2000
+ display: block !important;
2001
+ }
2002
+
2003
+ .download-limiter-btn.cancel-btn:hover {
2004
+ color: #374151 !important;
2005
+ background: rgba(107, 114, 128, 0.1) !important;
2006
+ text-decoration: none !important;
2007
+ }
2008
+
2009
+ /* Theme-specific cancel button border */
2010
+ [data-theme="dark"] .download-limiter-cancel-container {
2011
+ border-top-color: rgba(255, 255, 255, 0.1) !important;
2012
+ }
2013
+
2014
+ [data-theme="dark"] .download-limiter-btn.cancel-btn {
2015
+ color: #9ca3af !important;
2016
+ }
2017
+
2018
+ [data-theme="dark"] .download-limiter-btn.cancel-btn:hover {
2019
+ color: #d1d5db !important;
2020
+ background: rgba(156, 163, 175, 0.1) !important;
2021
+ }
2022
+
2023
+ [data-theme="cyberpunk"] .download-limiter-cancel-container {
2024
+ border-top-color: rgba(14, 165, 233, 0.2) !important;
2025
+ }
2026
+
2027
+ [data-theme="cyberpunk"] .download-limiter-btn.cancel-btn {
2028
+ color: #0ea5e9 !important;
2029
+ }
2030
+
2031
+ [data-theme="cyberpunk"] .download-limiter-btn.cancel-btn:hover {
2032
+ color: #38bdf8 !important;
2033
+ background: rgba(14, 165, 233, 0.1) !important;
2034
+ }
2035
+ `;
2036
+ document.head.appendChild(styles);
2037
+ }
2038
+ injectDaisyUI() {
2039
+ //console.log('🎨 [THEME DEBUG] injectDaisyUI called');
2040
+ //console.log('🎨 [THEME DEBUG] Theme config:', this.config.theme);
2041
+ // Check if DaisyUI is already loaded
2042
+ const existingLink = document.querySelector('link[href*="daisyui"]');
2043
+ if (existingLink) {
2044
+ //console.log('🎨 [THEME DEBUG] DaisyUI already exists:', existingLink);
2045
+ // Apply theme if DaisyUI already exists
2046
+ if (this.config.theme?.name) {
2047
+ const themeName = this.config.theme.name.toLowerCase();
2048
+ //console.log('🎨 [THEME DEBUG] Setting existing theme:', themeName);
2049
+ document.documentElement.setAttribute('data-theme', themeName);
2050
+ //console.log('🎨 [THEME DEBUG] Current data-theme attribute:', document.documentElement.getAttribute('data-theme'));
2051
+ }
2052
+ return;
2053
+ }
2054
+ //console.log('🎨 [THEME DEBUG] No existing DaisyUI found, injecting...');
2055
+ // Note: Tailwind CSS is not needed as we use custom CSS for all styling
2056
+ // Apply theme directly using our custom CSS - no external dependencies needed
2057
+ if (this.config.theme?.name) {
2058
+ const themeName = this.config.theme.name.toLowerCase();
2059
+ document.documentElement.setAttribute('data-theme', themeName);
2060
+ // Update status displays immediately since no CSS loading is needed
2061
+ this.updateStatusDisplays();
2062
+ }
2063
+ }
2064
+ createPaywallModal() {
2065
+ if (document.getElementById('download-limiter-paywall'))
2066
+ return;
2067
+ const modal = document.createElement('div');
2068
+ modal.id = 'download-limiter-paywall';
2069
+ modal.className = 'download-limiter-modal';
2070
+ modal.innerHTML = `
2071
+ <div class="download-limiter-content">
2072
+ <h3 id="download-limiter-paywall-title">Usage Limit Reached</h3>
2073
+ <p id="download-limiter-paywall-subtitle">You've used all your free attempts. Upgrade to premium for unlimited usage!</p>
2074
+
2075
+ <!-- Auth Section (shows when not signed in) -->
2076
+ <div id="download-limiter-auth-section" style="margin: 20px 0;">
2077
+ <p>Sign in to continue or upgrade to premium</p>
2078
+ <button id="download-limiter-signin-btn" class="download-limiter-btn google-signin-btn">
2079
+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none">
2080
+ <path d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a8.8 8.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18z" fill="white"/>
2081
+ <path d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2.04a4.8 4.8 0 0 1-2.7.75 4.8 4.8 0 0 1-4.52-3.4H1.83v2.07A8 8 0 0 0 8.98 17z" fill="white"/>
2082
+ <path d="M4.46 10.37a4.8 4.8 0 0 1-.25-1.37c0-.48.09-.94.25-1.37V5.56H1.83a8 8 0 0 0 0 6.88l2.63-2.07z" fill="white"/>
2083
+ <path d="M8.98 3.77c1.32 0 2.5.45 3.44 1.35l2.58-2.58C13.94.64 11.66 0 8.98 0A8 8 0 0 0 1.83 5.56l2.63 2.07c.61-1.8 2.26-3.86 4.52-3.86z" fill="white"/>
2084
+ </svg>
2085
+ Sign in with Google
2086
+ </button>
2087
+ </div>
2088
+
2089
+ <!-- Payment Section (shows when signed in) -->
2090
+ <div id="download-limiter-payment-section" style="margin: 20px 0; display: none;">
2091
+ <button id="download-limiter-upgrade-btn" class="download-limiter-btn upgrade-btn">
2092
+ Upgrade to Premium
2093
+ </button>
2094
+ </div>
2095
+
2096
+ <div class="download-limiter-cancel-container">
2097
+ <button id="download-limiter-close-btn" class="download-limiter-btn cancel-btn">
2098
+ Cancel
2099
+ </button>
2100
+ </div>
2101
+ </div>
2102
+ `;
2103
+ document.body.appendChild(modal);
2104
+ // Set up event handlers
2105
+ modal.querySelector('#download-limiter-signin-btn').addEventListener('click', async () => {
2106
+ await this.signIn();
2107
+ });
2108
+ modal.querySelector('#download-limiter-upgrade-btn').addEventListener('click', async () => {
2109
+ const payment = await this.createPayment();
2110
+ if (payment?.checkout_url) {
2111
+ window.location.href = payment.checkout_url;
2112
+ }
2113
+ });
2114
+ modal.querySelector('#download-limiter-close-btn').addEventListener('click', () => {
2115
+ if (this.config.options?.debug) {
2116
+ console.log('🔍 DEBUG: Cancel button clicked');
2117
+ console.log('🔍 DEBUG: this.config.feedback:', this.config.feedback);
2118
+ console.log('🔍 DEBUG: this.config.email:', this.config.email);
2119
+ console.log('🔍 DEBUG: Feedback config exists:', !!(this.config.feedback || this.config.email));
2120
+ }
2121
+ // Show feedback form if feedback config exists, otherwise just close
2122
+ if (this.config.feedback || this.config.email) {
2123
+ if (this.config.options?.debug) {
2124
+ console.log('🔍 DEBUG: Showing feedback form');
2125
+ }
2126
+ this.showFeedbackForm();
2127
+ }
2128
+ else {
2129
+ if (this.config.options?.debug) {
2130
+ console.log('🔍 DEBUG: No email config, just closing modal');
2131
+ }
2132
+ modal.classList.remove('show');
2133
+ }
2134
+ });
2135
+ // Removed click-outside-to-close behavior to encourage users to use the Cancel button
2136
+ // which triggers the feedback form. This improves feedback collection.
2137
+ }
2138
+ createSuccessModal() {
2139
+ if (document.getElementById('download-limiter-success'))
2140
+ return;
2141
+ const modal = document.createElement('div');
2142
+ modal.id = 'download-limiter-success';
2143
+ modal.className = 'download-limiter-modal'; // Use same modal class as paywall
2144
+ modal.innerHTML = `
2145
+ <div class="download-limiter-content"> <!-- Use same content class as paywall for theming -->
2146
+ <h3 id="download-limiter-success-title">Action Started!</h3>
2147
+ <p id="download-limiter-success-message">Your action completed successfully!</p>
2148
+ <button id="download-limiter-success-close" class="download-limiter-btn success-btn">
2149
+ OK
2150
+ </button>
2151
+ </div>
2152
+ `;
2153
+ document.body.appendChild(modal);
2154
+ // Set up event handlers
2155
+ modal.querySelector('#download-limiter-success-close').addEventListener('click', () => {
2156
+ modal.classList.remove('show');
2157
+ });
2158
+ modal.addEventListener('click', (e) => {
2159
+ if (e.target === modal) {
2160
+ modal.classList.remove('show');
2161
+ }
2162
+ });
2163
+ }
2164
+ showFeedbackForm() {
2165
+ // const feedbackStartTime = Date.now();
2166
+ // console.log(`🕐 [FEEDBACK] showFeedbackForm called: ${new Date(feedbackStartTime).toISOString()}`);
2167
+ // Hide paywall first
2168
+ // const paywallHideStart = Date.now();
2169
+ const paywall = document.getElementById('download-limiter-paywall');
2170
+ if (paywall) {
2171
+ paywall.classList.remove('show');
2172
+ // console.log(`🕐 [FEEDBACK] Paywall hidden: ${Date.now() - paywallHideStart}ms`);
2173
+ }
2174
+ // Create or show feedback modal
2175
+ // const createFeedbackStart = Date.now();
2176
+ this.createFeedbackModal();
2177
+ // console.log(`🕐 [FEEDBACK] createFeedbackModal completed: ${Date.now() - createFeedbackStart}ms`);
2178
+ const modal = document.getElementById('download-limiter-feedback');
2179
+ if (modal) {
2180
+ modal.classList.add('show');
2181
+ // console.log(`🕐 [FEEDBACK] Feedback modal shown: ${Date.now() - feedbackStartTime}ms total`);
2182
+ }
2183
+ else {
2184
+ // console.log(`🕐 [FEEDBACK] ERROR - Feedback modal not found after ${Date.now() - feedbackStartTime}ms`);
2185
+ }
2186
+ }
2187
+ createFeedbackModal() {
2188
+ if (document.getElementById('download-limiter-feedback')) {
2189
+ if (this.config.options?.debug) {
2190
+ console.log('🔍 DEBUG: Feedback modal already exists');
2191
+ }
2192
+ return;
2193
+ }
2194
+ // Get feedback configuration or fallback to legacy email config
2195
+ const feedbackConfig = this.config.feedback || (this.config.email ? {
2196
+ form: {
2197
+ title: 'Quick Feedback',
2198
+ description: 'Why didn\'t you upgrade?',
2199
+ option1: 'Not useful for my needs',
2200
+ option2: 'Didn\'t find what I was looking for',
2201
+ option3: 'Just trying it out'
2202
+ },
2203
+ email: this.config.email
2204
+ } : null);
2205
+ if (this.config.options?.debug) {
2206
+ console.log('🔍 DEBUG: Feedback config:', feedbackConfig);
2207
+ console.log('🔍 DEBUG: this.config.feedback:', this.config.feedback);
2208
+ console.log('🔍 DEBUG: this.config.email:', this.config.email);
2209
+ }
2210
+ if (!feedbackConfig) {
2211
+ if (this.config.options?.debug) {
2212
+ console.log('🔍 DEBUG: No feedback config found, not creating modal');
2213
+ }
2214
+ return;
2215
+ }
2216
+ const modal = document.createElement('div');
2217
+ modal.id = 'download-limiter-feedback';
2218
+ modal.className = 'download-limiter-modal';
2219
+ modal.innerHTML = `
2220
+ <div class="download-limiter-content">
2221
+ <h3>${feedbackConfig.form.title}</h3>
2222
+ <p style="margin-bottom: 20px;">${feedbackConfig.form.description}</p>
2223
+
2224
+ <form id="feedback-form" style="text-align: left;">
2225
+ <div style="margin-bottom: 15px;">
2226
+ <label style="display: block; margin-bottom: 8px;">
2227
+ <input type="radio" name="reason" value="option1" style="margin-right: 8px;">
2228
+ ${feedbackConfig.form.option1}
2229
+ </label>
2230
+ <label style="display: block; margin-bottom: 8px;">
2231
+ <input type="radio" name="reason" value="option2" style="margin-right: 8px;">
2232
+ ${feedbackConfig.form.option2}
2233
+ </label>
2234
+ <label style="display: block; margin-bottom: 8px;">
2235
+ <input type="radio" name="reason" value="option3" style="margin-right: 8px;">
2236
+ ${feedbackConfig.form.option3}
2237
+ </label>
2238
+ </div>
2239
+
2240
+ <div style="margin-bottom: 15px;">
2241
+ <label for="feedback-details" style="display: block; margin-bottom: 5px;">Tell us more:</label>
2242
+ <textarea
2243
+ id="feedback-details"
2244
+ name="details"
2245
+ rows="3"
2246
+ style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;"
2247
+ placeholder="Your feedback helps us improve..." maxlength="200"></textarea>
2248
+ </div>
2249
+
2250
+ <div style="margin-bottom: 20px;">
2251
+ <label for="feedback-email" style="display: block; margin-bottom: 5px;">
2252
+ Email (optional):
2253
+ </label>
2254
+ <input
2255
+ type="email"
2256
+ id="feedback-email"
2257
+ name="email"
2258
+ style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;"
2259
+ placeholder="your@email.com">
2260
+ <small style="color: #666; display: block; margin-top: 4px;">
2261
+ Only if you want us to reach out about what you mentioned above. We don't follow up unless you want us to
2262
+ </small>
2263
+ </div>
2264
+
2265
+
2266
+ <div style="text-align: center;">
2267
+ <button type="submit" class="download-limiter-btn success-btn" style="margin-right: 10px;">
2268
+ Submit Feedback
2269
+ </button>
2270
+ <button type="button" id="feedback-skip-btn" class="download-limiter-btn cancel-btn">
2271
+ Skip
2272
+ </button>
2273
+ </div>
2274
+ </form>
2275
+ </div>
2276
+ `;
2277
+ document.body.appendChild(modal);
2278
+ if (this.config.options?.debug) {
2279
+ console.log('🔍 DEBUG: Feedback modal created and added to DOM');
2280
+ }
2281
+ // Set up event listeners
2282
+ const form = modal.querySelector('#feedback-form');
2283
+ form.addEventListener('submit', (e) => {
2284
+ e.preventDefault();
2285
+ this.submitFeedback(form);
2286
+ });
2287
+ modal.querySelector('#feedback-skip-btn').addEventListener('click', () => {
2288
+ modal.classList.remove('show');
2289
+ });
2290
+ modal.addEventListener('click', (e) => {
2291
+ if (e.target === modal) {
2292
+ modal.classList.remove('show');
2293
+ }
2294
+ });
2295
+ }
2296
+ async submitFeedback(form) {
2297
+ const formData = new FormData(form);
2298
+ const reason = formData.get('reason');
2299
+ const details = formData.get('details');
2300
+ const email = formData.get('email');
2301
+ if (!reason) {
2302
+ alert('Please select a reason');
2303
+ return;
2304
+ }
2305
+ const feedbackData = {
2306
+ reason,
2307
+ details,
2308
+ email: email || undefined,
2309
+ timestamp: new Date().toISOString(),
2310
+ userAgent: navigator.userAgent,
2311
+ appId: this.config.appId
2312
+ };
2313
+ try {
2314
+ await this.sendFeedbackEmail(feedbackData);
2315
+ // Close feedback modal
2316
+ const modal = document.getElementById('download-limiter-feedback');
2317
+ if (modal) {
2318
+ modal.classList.remove('show');
2319
+ }
2320
+ // Show thank you message
2321
+ alert('Thank you for your feedback!');
2322
+ }
2323
+ catch (error) {
2324
+ console.error('Failed to send feedback:', error);
2325
+ alert('Failed to send feedback. Please try again.');
2326
+ }
2327
+ }
2328
+ async sendFeedbackEmail(feedbackData) {
2329
+ const emailConfig = this.config.feedback?.email || this.config.email;
2330
+ if (!emailConfig) {
2331
+ throw new Error('Email configuration not available');
2332
+ }
2333
+ const emailBody = `
2334
+ New Feedback from ${this.config.appId}
2335
+
2336
+ Reason: ${feedbackData.reason}
2337
+ Details: ${feedbackData.details}
2338
+ User Email: ${feedbackData.email || 'Not provided'}
2339
+ Timestamp: ${feedbackData.timestamp}
2340
+ User Agent: ${feedbackData.userAgent}
2341
+ `.trim();
2342
+ const response = await fetch('https://api.resend.com/emails', {
2343
+ method: 'POST',
2344
+ headers: {
2345
+ 'Content-Type': 'application/json',
2346
+ 'Authorization': `Bearer ${emailConfig.resendApiKey}`
2347
+ },
2348
+ body: JSON.stringify({
2349
+ from: emailConfig.fromEmail,
2350
+ to: [emailConfig.fromEmail], // Send feedback to yourself
2351
+ subject: `Feedback from ${this.config.appId}`,
2352
+ text: emailBody
2353
+ })
2354
+ });
2355
+ if (!response.ok) {
2356
+ throw new Error(`Email API error: ${response.status}`);
2357
+ }
2358
+ }
2359
+ createAuthUI() {
2360
+ if (document.getElementById('lead-fast-profile'))
2361
+ return;
2362
+ const profileContainer = document.createElement('div');
2363
+ profileContainer.id = 'lead-fast-profile';
2364
+ profileContainer.className = 'lead-fast-profile';
2365
+ document.body.appendChild(profileContainer);
2366
+ }
2367
+ createStatusDisplay() {
2368
+ if (document.getElementById('download-limiter-status'))
2369
+ return;
2370
+ const statusDiv = document.createElement('div');
2371
+ statusDiv.id = 'download-limiter-status';
2372
+ statusDiv.className = 'download-limiter-status';
2373
+ document.body.appendChild(statusDiv);
2374
+ }
2375
+ createGlobalStatusDisplay() {
2376
+ this.createStatusDisplay();
2377
+ }
2378
+ showPaywallInstant(status) {
2379
+ // const showStartTime = Date.now();
2380
+ // console.log(`🕐 [MODAL] showPaywallInstant started: ${new Date(showStartTime).toISOString()}`);
2381
+ // Ensure modal exists before trying to show it
2382
+ // const createStartTime = Date.now();
2383
+ this.createPaywallModal();
2384
+ // console.log(`🕐 [MODAL] createPaywallModal completed: ${Date.now() - createStartTime}ms`);
2385
+ const modal = document.getElementById('download-limiter-paywall');
2386
+ if (modal) {
2387
+ // console.log(`🕐 [MODAL] Modal found in DOM: ${Date.now() - showStartTime}ms`);
2388
+ // Update paywall title with exact count (no API call needed)
2389
+ const titleEl = modal.querySelector('#download-limiter-paywall-title');
2390
+ if (titleEl) {
2391
+ titleEl.textContent = `You've used ${status.limit} free attempts`;
2392
+ // console.log(`🕐 [MODAL] Title updated: ${Date.now() - showStartTime}ms`);
2393
+ }
2394
+ // Show appropriate section based on auth state
2395
+ const authSection = modal.querySelector('#download-limiter-auth-section');
2396
+ const paymentSection = modal.querySelector('#download-limiter-payment-section');
2397
+ if (!this.currentUser) {
2398
+ // console.log(`🕐 [MODAL] Setting up anonymous user flow: ${Date.now() - showStartTime}ms`);
2399
+ // Anonymous user - show single upgrade flow
2400
+ const subtitleEl = modal.querySelector('#download-limiter-paywall-subtitle');
2401
+ if (subtitleEl) {
2402
+ subtitleEl.textContent = 'Sign in to continue. If you\'re already premium, you\'ll get unlimited access. New users can upgrade after signing in.';
2403
+ }
2404
+ // Hide separate auth/payment sections and show single upgrade button
2405
+ authSection.style.display = 'none';
2406
+ paymentSection.style.display = 'none';
2407
+ // Show single upgrade button
2408
+ // const upgradeStartTime = Date.now();
2409
+ this.showSingleUpgradeFlow(modal);
2410
+ // console.log(`🕐 [MODAL] Single upgrade flow setup: ${Date.now() - upgradeStartTime}ms`);
2411
+ }
2412
+ else {
2413
+ // console.log(`🕐 [MODAL] Setting up signed-in user flow: ${Date.now() - showStartTime}ms`);
2414
+ // Existing flow for signed-in users - direct to payment
2415
+ authSection.style.display = 'none';
2416
+ paymentSection.style.display = 'block';
2417
+ }
2418
+ modal.classList.add('show');
2419
+ // console.log(`🕐 [MODAL] Modal shown (classList.add('show')): ${Date.now() - showStartTime}ms`);
2420
+ }
2421
+ else {
2422
+ // console.log(`🕐 [MODAL] ERROR: Modal not found in DOM after creation: ${Date.now() - showStartTime}ms`);
2423
+ }
2424
+ }
2425
+ async showPaywall() {
2426
+ // Get current status if not cached
2427
+ const status = await this.getDownloadStatus();
2428
+ this.showPaywallInstant(status);
2429
+ }
2430
+ showSingleUpgradeFlow(modal) {
2431
+ // Create single upgrade button that handles both login and payment
2432
+ let upgradeContainer = modal.querySelector('.single-upgrade-container');
2433
+ if (!upgradeContainer) {
2434
+ upgradeContainer = document.createElement('div');
2435
+ upgradeContainer.className = 'single-upgrade-container';
2436
+ upgradeContainer.innerHTML = `
2437
+ <div class="single-upgrade-content">
2438
+ <button class="download-limiter-btn upgrade-btn" id="single-upgrade-btn">
2439
+ Continue with Google
2440
+ </button>
2441
+ <!--<p class="upgrade-description">
2442
+ Sign in to restore access. Premium members get unlimited usage immediately.
2443
+ </p>-->
2444
+ </div>
2445
+ `;
2446
+ // Insert before the cancel container to keep cancel at the bottom
2447
+ const cancelContainer = modal.querySelector('.download-limiter-cancel-container');
2448
+ if (cancelContainer) {
2449
+ modal.querySelector('.download-limiter-content')?.insertBefore(upgradeContainer, cancelContainer);
2450
+ }
2451
+ else {
2452
+ modal.querySelector('.download-limiter-content')?.appendChild(upgradeContainer);
2453
+ }
2454
+ }
2455
+ upgradeContainer.style.display = 'block';
2456
+ // Add click handler for single upgrade flow
2457
+ const upgradeBtn = modal.querySelector('#single-upgrade-btn');
2458
+ if (upgradeBtn) {
2459
+ upgradeBtn.replaceWith(upgradeBtn.cloneNode(true)); // Remove existing listeners
2460
+ const newUpgradeBtn = modal.querySelector('#single-upgrade-btn');
2461
+ newUpgradeBtn?.addEventListener('click', async () => {
2462
+ try {
2463
+ // Step 1: Sign in with Google
2464
+ const { error } = await this.supabase.auth.signInWithOAuth({
2465
+ provider: 'google',
2466
+ options: {
2467
+ redirectTo: `${window.location.origin}${window.location.pathname}?upgrade=true`
2468
+ }
2469
+ });
2470
+ if (error) {
2471
+ console.error('Sign in error:', error);
2472
+ this.showError('Sign In Failed', 'Failed to sign in with Google. Please try again.');
2473
+ }
2474
+ // OAuth will redirect, so no further action needed here
2475
+ }
2476
+ catch (error) {
2477
+ console.error('Upgrade flow error:', error);
2478
+ this.showError('Upgrade Failed', 'Failed to start upgrade process. Please try again.');
2479
+ }
2480
+ });
2481
+ }
2482
+ }
2483
+ showSuccess(title, message) {
2484
+ const modal = document.getElementById('download-limiter-success');
2485
+ if (modal) {
2486
+ const titleEl = modal.querySelector('#download-limiter-success-title');
2487
+ const messageEl = modal.querySelector('#download-limiter-success-message');
2488
+ if (titleEl)
2489
+ titleEl.textContent = title;
2490
+ if (messageEl)
2491
+ messageEl.textContent = message;
2492
+ modal.classList.add('show');
2493
+ // No auto-hide - let user dismiss manually
2494
+ }
2495
+ }
2496
+ showError(title, message) {
2497
+ // Create a clean error toast instead of alert
2498
+ const toast = document.createElement('div');
2499
+ toast.style.cssText = `
2500
+ position: fixed;
2501
+ top: 20px;
2502
+ right: 20px;
2503
+ background: #fee2e2;
2504
+ border: 1px solid #fecaca;
2505
+ color: #dc2626;
2506
+ padding: 12px 16px;
2507
+ border-radius: 8px;
2508
+ font-size: 14px;
2509
+ font-weight: 500;
2510
+ line-height: 1.4;
2511
+ max-width: 300px;
2512
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
2513
+ z-index: 10000;
2514
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
2515
+ `;
2516
+ toast.innerHTML = `
2517
+ <div style="font-weight: 600; margin-bottom: 4px;">${title}</div>
2518
+ <div style="font-size: 13px; opacity: 0.9;">${message}</div>
2519
+ `;
2520
+ document.body.appendChild(toast);
2521
+ // Auto-remove after 5 seconds
2522
+ setTimeout(() => {
2523
+ if (toast.parentNode) {
2524
+ toast.parentNode.removeChild(toast);
2525
+ }
2526
+ }, 5000);
2527
+ // Click to dismiss
2528
+ toast.addEventListener('click', () => {
2529
+ if (toast.parentNode) {
2530
+ toast.parentNode.removeChild(toast);
2531
+ }
2532
+ });
2533
+ }
2534
+ showConnectionError() {
2535
+ this.showError('Connection Error', 'Server connection required for download verification. Please check your configuration and try again.');
2536
+ }
2537
+ showPaymentConfigError() {
2538
+ this.showError('Payment Configuration Error', 'Payment system is not properly configured. Please contact support.');
2539
+ }
2540
+ disableDownloadButtons(errorType) {
2541
+ // Find all buttons that were attached by the library
2542
+ const buttons = document.querySelectorAll('[data-leadfast-attached]');
2543
+ const errorMessages = {
2544
+ connection: 'Download disabled: Server connection required',
2545
+ payment: 'Download disabled: Payment configuration error'
2546
+ };
2547
+ const statusMessages = {
2548
+ connection: '⚠️ Connection Error - Downloads Disabled',
2549
+ payment: '⚠️ Payment Config Error - Downloads Disabled'
2550
+ };
2551
+ buttons.forEach(button => {
2552
+ const btnElement = button;
2553
+ btnElement.disabled = true;
2554
+ btnElement.style.opacity = '0.5';
2555
+ btnElement.style.cursor = 'not-allowed';
2556
+ btnElement.title = errorMessages[errorType];
2557
+ });
2558
+ // Update user section to show error
2559
+ const userSection = document.querySelector('.lead-fast-user-section');
2560
+ if (userSection) {
2561
+ userSection.innerHTML = `
2562
+ <div style="
2563
+ color: #ef4444;
2564
+ padding: 6px 8px;
2565
+ font-size: 12px;
2566
+ font-weight: 500;
2567
+ line-height: 1.2;
2568
+ border-radius: 4px;
2569
+ background: rgba(239, 68, 68, 0.05);
2570
+ border: 1px solid rgba(239, 68, 68, 0.2);
2571
+ max-width: 200px;
2572
+ text-align: center;
2573
+ ">
2574
+ ${statusMessages[errorType]}
2575
+ </div>
2576
+ `;
2577
+ }
2578
+ }
2579
+ async updateStatusDisplays() {
2580
+ //console.log('🎨 [THEME DEBUG] updateStatusDisplays called');
2581
+ // If connection failed, disable all download buttons
2582
+ if (this.supabaseConnectionFailed) {
2583
+ this.disableDownloadButtons('connection');
2584
+ return;
2585
+ }
2586
+ // If payment configuration is invalid, disable all download buttons
2587
+ if (this.config.payment && this.paymentConnectionFailed) {
2588
+ this.disableDownloadButtons('payment');
2589
+ return;
2590
+ }
2591
+ const status = await this.getDownloadStatus();
2592
+ this.updateUserSection(status);
2593
+ }
2594
+ createTitleBar() {
2595
+ //console.log('🎨 [THEME DEBUG] Creating title bar');
2596
+ // Create the profile div if it doesn't exist
2597
+ let profileDiv = document.getElementById('lead-fast-profile');
2598
+ if (!profileDiv) {
2599
+ profileDiv = document.createElement('div');
2600
+ profileDiv.id = 'lead-fast-profile';
2601
+ profileDiv.className = 'lead-fast-profile';
2602
+ document.body.appendChild(profileDiv);
2603
+ }
2604
+ // Get title bar configuration
2605
+ const titleConfig = this.config.titleBar || {};
2606
+ const title = titleConfig.title || 'My App';
2607
+ const titleImage = titleConfig.titleImage;
2608
+ const links = titleConfig.links || [];
2609
+ // Always create title bar with logo and navigation
2610
+ profileDiv.innerHTML = `
2611
+ <div class="lead-fast-title-bar">
2612
+ <div class="lead-fast-title-section">
2613
+ <a href="#" class="lead-fast-logo">
2614
+ ${titleImage ? `<img src="${titleImage}" alt="${title}">` : ''}
2615
+ <span>${title}</span>
2616
+ </a>
2617
+ <nav class="lead-fast-nav">
2618
+ ${links.map(link => `
2619
+ <a href="${link.url}" class="lead-fast-nav-link" ${link.target ? `target="${link.target}"` : ''}>
2620
+ ${link.text}
2621
+ </a>
2622
+ `).join('')}
2623
+ </nav>
2624
+ </div>
2625
+
2626
+ <div class="lead-fast-user-section" id="lead-fast-user-section">
2627
+ <!-- User section will be populated when logged in -->
2628
+ </div>
2629
+
2630
+ <!-- <a href="https://www.moneyfast.bar" target="_blank" class="lead-fast-branding" style="text-decoration: none; color: inherit;">moneyfast.bar</a>-->
2631
+ </div>
2632
+ `;
2633
+ }
2634
+ updateUserSection(status) {
2635
+ //console.log('🎨 [THEME DEBUG] updateUserSection called');
2636
+ //console.log('🎨 [THEME DEBUG] Current data-theme:', document.documentElement.getAttribute('data-theme'));
2637
+ const userSection = document.getElementById('lead-fast-user-section');
2638
+ if (!userSection) {
2639
+ //console.log('🎨 [THEME DEBUG] User section not found!');
2640
+ return;
2641
+ }
2642
+ if (this.currentUser) {
2643
+ // User is signed in - show user info
2644
+ const userInitial = this.currentUser.email.charAt(0).toUpperCase();
2645
+ const userEmail = this.currentUser.email;
2646
+ const badgeClass = status.isPremium ? 'premium' : 'free';
2647
+ const badgeText = status.isPremium ? 'Premium' : 'Free';
2648
+ const countText = status.isPremium ? 'Unlimited' : `${status.currentCount}/${status.limit}`;
2649
+ //console.log('🎨 [THEME DEBUG] Populating user section');
2650
+ userSection.innerHTML = `
2651
+ <div class="lead-fast-avatar">${userInitial}</div>
2652
+ <div class="lead-fast-user-info">
2653
+ <div class="lead-fast-user-email">${userEmail}</div>
2654
+ <div class="lead-fast-user-status">
2655
+ <span class="lead-fast-badge ${badgeClass}">${badgeText}</span>
2656
+ <span class="lead-fast-count">${countText}</span>
2657
+ </div>
2658
+ </div>
2659
+ <button class="lead-fast-signout">signout</button>
2660
+ `;
2661
+ // Debug CSS variables after updating user section
2662
+ const titleBar = document.querySelector('.lead-fast-title-bar');
2663
+ if (titleBar) {
2664
+ const computedStyle = getComputedStyle(titleBar);
2665
+ //console.log('🎨 [THEME DEBUG] Title bar background color:', computedStyle.backgroundColor);
2666
+ //console.log('🎨 [THEME DEBUG] Title bar border color:', computedStyle.borderColor);
2667
+ }
2668
+ // Add sign out functionality
2669
+ const signoutBtn = userSection.querySelector('.lead-fast-signout');
2670
+ if (signoutBtn) {
2671
+ signoutBtn.addEventListener('click', () => {
2672
+ this.signOut();
2673
+ });
2674
+ }
2675
+ }
2676
+ else {
2677
+ // Anonymous user - show usage count
2678
+ //console.log('🎨 [THEME DEBUG] Showing anonymous user usage count');
2679
+ const countText = `Attempts: ${status.currentCount}/${status.limit}`;
2680
+ userSection.innerHTML = `
2681
+ <div class="lead-fast-anonymous-status">
2682
+ <span class="lead-fast-count">${countText}</span>
2683
+ </div>
2684
+ `;
2685
+ }
2686
+ }
2687
+ setupUIUpdates() {
2688
+ // Update UI on auth changes
2689
+ this.on('authChanged', async () => {
2690
+ // Invalidate cache when auth state changes
2691
+ // console.log(`🕐 [CACHE] Invalidating cache due to auth change (was: ${this.cachedStatus ? 'cached' : 'null'})`);
2692
+ this.cachedStatus = null;
2693
+ this.updateStatusDisplays();
2694
+ // Update paywall display if it's currently shown
2695
+ const modal = document.getElementById('download-limiter-paywall');
2696
+ if (modal && modal.classList.contains('show')) {
2697
+ this.updatePaywallDisplay();
2698
+ // Auto-redirect to payment after sign-in from paywall (if not already premium)
2699
+ if (this.currentUser && this.config.payment) {
2700
+ setTimeout(async () => {
2701
+ const isPremium = await this.checkPremiumStatus(this.currentUser.email);
2702
+ if (!isPremium) {
2703
+ // User is not premium, redirect to payment
2704
+ const payment = await this.createPayment();
2705
+ if (payment?.checkout_url) {
2706
+ window.location.href = payment.checkout_url;
2707
+ }
2708
+ }
2709
+ else {
2710
+ // User is already premium, just close paywall and stay on page
2711
+ modal.classList.remove('show');
2712
+ }
2713
+ }, 1000); // Small delay to let UI update
2714
+ }
2715
+ }
2716
+ });
2717
+ // Update UI on count changes
2718
+ this.on('countChanged', () => {
2719
+ this.updateStatusDisplays();
2720
+ });
2721
+ // Initial update
2722
+ this.updateStatusDisplays();
2723
+ }
2724
+ updatePaywallDisplay() {
2725
+ const modal = document.getElementById('download-limiter-paywall');
2726
+ if (!modal)
2727
+ return;
2728
+ const authSection = modal.querySelector('#download-limiter-auth-section');
2729
+ const paymentSection = modal.querySelector('#download-limiter-payment-section');
2730
+ if (!this.currentUser) {
2731
+ // Not signed in - show auth section
2732
+ authSection.style.display = 'block';
2733
+ paymentSection.style.display = 'none';
2734
+ }
2735
+ else {
2736
+ // Signed in - show payment section
2737
+ authSection.style.display = 'none';
2738
+ paymentSection.style.display = 'block';
2739
+ }
2740
+ }
2741
+ /**
2742
+ * Event listener management
2743
+ */
2744
+ on(event, listener) {
2745
+ if (!this.eventListeners.has(event)) {
2746
+ this.eventListeners.set(event, []);
2747
+ }
2748
+ this.eventListeners.get(event).push(listener);
2749
+ }
2750
+ off(event, listener) {
2751
+ const listeners = this.eventListeners.get(event);
2752
+ if (listeners) {
2753
+ const index = listeners.indexOf(listener);
2754
+ if (index > -1) {
2755
+ listeners.splice(index, 1);
2756
+ }
2757
+ }
2758
+ }
2759
+ emit(event, data) {
2760
+ const listeners = this.eventListeners.get(event);
2761
+ if (listeners) {
2762
+ listeners.forEach(listener => {
2763
+ try {
2764
+ listener(data);
2765
+ }
2766
+ catch (error) {
2767
+ console.error(`Error in ${event} listener:`, error);
2768
+ }
2769
+ });
2770
+ }
2771
+ }
2772
+ validateConfig() {
2773
+ if (!this.config.appId)
2774
+ throw new Error('appId is required');
2775
+ if (!this.config.supabase?.url)
2776
+ throw new Error('supabase.url is required');
2777
+ if (!this.config.supabase?.anonKey)
2778
+ throw new Error('supabase.anonKey is required');
2779
+ if (typeof this.config.freeDownloadLimit !== 'number' || this.config.freeDownloadLimit < 0) {
2780
+ throw new Error('freeDownloadLimit must be a non-negative number');
2781
+ }
2782
+ }
2783
+ async initializeSupabase() {
2784
+ try {
2785
+ this.supabase = createClient(this.config.supabase.url, this.config.supabase.anonKey);
2786
+ // Skip connection test - we'll detect connection issues during actual API calls
2787
+ this.supabaseConnectionFailed = false;
2788
+ }
2789
+ catch (error) {
2790
+ console.error('Failed to initialize Supabase:', error);
2791
+ this.supabaseConnectionFailed = true;
2792
+ }
2793
+ }
2794
+ async initializePayment() {
2795
+ // Skip if no payment configuration
2796
+ if (!this.config.payment) {
2797
+ return;
2798
+ }
2799
+ // Validate product ID format
2800
+ const productId = this.config.payment.productId;
2801
+ if (!productId || !productId.startsWith('pdt_') || productId.length < 10) {
2802
+ this.paymentConnectionFailed = true;
2803
+ if (this.config.options?.debug) {
2804
+ console.warn('Invalid payment product ID format:', productId);
2805
+ }
2806
+ return;
2807
+ }
2808
+ // For now, skip payment gateway connectivity test
2809
+ // Only validate product ID format (which we already did above)
2810
+ // In production, you can add actual DodoPayments API test here
2811
+ this.paymentConnectionFailed = false;
2812
+ }
2813
+ async initializeFingerprint() {
2814
+ try {
2815
+ this.userFingerprint = await this.generateFingerprint();
2816
+ }
2817
+ catch (error) {
2818
+ this.userFingerprint = crypto.randomUUID ? crypto.randomUUID() : String(Date.now());
2819
+ if (this.config.options?.debug) {
2820
+ console.warn('Fingerprint generation failed, using fallback:', error);
2821
+ }
2822
+ }
2823
+ }
2824
+ async generateFingerprint() {
2825
+ const ua = navigator.userAgent || '';
2826
+ const tz = Intl.DateTimeFormat().resolvedOptions().timeZone || '';
2827
+ const screenSize = `${screen.width}x${screen.height}`;
2828
+ const lang = navigator.language || '';
2829
+ const raw = `${ua}||${tz}||${screenSize}||${lang}`;
2830
+ const buf = new TextEncoder().encode(raw);
2831
+ const hashBuffer = await crypto.subtle.digest('SHA-256', buf);
2832
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
2833
+ return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
2834
+ }
2835
+ async setupAuthListener() {
2836
+ this.supabase.auth.onAuthStateChange(async (event, session) => {
2837
+ const previousUser = this.currentUser;
2838
+ this.currentUser = session?.user || null;
2839
+ let isPremium = false;
2840
+ if (this.currentUser) {
2841
+ // Only check premium status if user changed or cache is expired
2842
+ const userChanged = !previousUser || previousUser.email !== this.currentUser.email;
2843
+ const cacheExpired = !this.cachedPremiumStatus || (Date.now() - this.premiumStatusCacheTime) > this.STATUS_CACHE_DURATION;
2844
+ if (userChanged || cacheExpired) {
2845
+ console.log(`🔥 [SUPABASE API] About to call checkPremiumStatus from setupAuthListener (userChanged: ${userChanged}, cacheExpired: ${cacheExpired})`);
2846
+ isPremium = await this.checkPremiumStatus(this.currentUser.email);
2847
+ // Cache the result
2848
+ this.cachedPremiumStatus = isPremium;
2849
+ this.premiumStatusCacheTime = Date.now();
2850
+ }
2851
+ else {
2852
+ // Use cached result
2853
+ isPremium = this.cachedPremiumStatus; // We know it's not null because cacheExpired is false
2854
+ console.log(`🔍 [CACHE] Using cached premium status from auth listener: ${isPremium}`);
2855
+ }
2856
+ }
2857
+ else {
2858
+ // Clear cache when user logs out
2859
+ this.cachedPremiumStatus = null;
2860
+ this.premiumStatusCacheTime = 0;
2861
+ }
2862
+ // Check if user just signed in for upgrade flow
2863
+ const urlParams = new URLSearchParams(window.location.search);
2864
+ const isUpgradeFlow = urlParams.get('upgrade') === 'true';
2865
+ if (event === 'SIGNED_IN' && !previousUser && this.currentUser && this.config.payment) {
2866
+ // Check if this is an upgrade flow (from anonymous trial)
2867
+ if (isUpgradeFlow) {
2868
+ if (!isPremium) {
2869
+ // User signed in for upgrade - redirect to payment immediately
2870
+ const payment = await this.createPayment();
2871
+ if (payment?.checkout_url) {
2872
+ // Clean URL before redirect
2873
+ window.history.replaceState({}, document.title, window.location.pathname);
2874
+ window.location.href = payment.checkout_url;
2875
+ }
2876
+ }
2877
+ else {
2878
+ // User is already premium, just clean URL and close modal
2879
+ window.history.replaceState({}, document.title, window.location.pathname);
2880
+ const modal = document.getElementById('download-limiter-paywall');
2881
+ if (modal) {
2882
+ modal.classList.remove('show');
2883
+ }
2884
+ }
2885
+ }
2886
+ }
2887
+ this.emit('authChanged', { user: this.currentUser, isPremium });
2888
+ });
2889
+ // Get initial auth state
2890
+ const { data: { user } } = await this.supabase.auth.getUser();
2891
+ this.currentUser = user;
2892
+ }
2893
+ async getDownloadCount() {
2894
+ if (!this.userFingerprint)
2895
+ return 0;
2896
+ console.log(`🔥 [SUPABASE API] getDownloadCount called | Time: ${new Date().toISOString()}`);
2897
+ try {
2898
+ const response = await fetch(`${this.config.supabase.url}/functions/v1/check-download-limit`, {
2899
+ method: 'POST',
2900
+ headers: {
2901
+ 'Content-Type': 'application/json',
2902
+ 'Authorization': `Bearer ${this.config.supabase.anonKey}`
2903
+ },
2904
+ body: JSON.stringify({
2905
+ fingerprint: this.userFingerprint,
2906
+ app_id: this.config.appId,
2907
+ action: 'check'
2908
+ })
2909
+ });
2910
+ console.log(`🔥 [SUPABASE API] getDownloadCount response: ${response.status}`);
2911
+ if (response.ok) {
2912
+ const data = await response.json();
2913
+ this.supabaseConnectionFailed = false; // Connection successful
2914
+ return data.current_count || 0;
2915
+ }
2916
+ else {
2917
+ // Handle auth errors (401/403) as connection failures
2918
+ if (response.status === 401 || response.status === 403) {
2919
+ console.warn(`Supabase authentication failed: ${response.status} - Invalid anon key`);
2920
+ this.supabaseConnectionFailed = true;
2921
+ }
2922
+ }
2923
+ }
2924
+ catch (error) {
2925
+ this.supabaseConnectionFailed = true; // Mark connection as failed
2926
+ if (this.config.options?.debug) {
2927
+ console.warn('Failed to get server usage count, connection failed:', error);
2928
+ }
2929
+ }
2930
+ // Security: Do not fallback to localStorage when server connection fails
2931
+ // This prevents users from bypassing limits by manipulating localStorage
2932
+ return 0;
2933
+ }
2934
+ async incrementDownloadCount() {
2935
+ if (!this.userFingerprint) {
2936
+ // if (this.config.options?.debug) {
2937
+ // console.warn('🔍 DEBUG: No userFingerprint available for incrementDownloadCount');
2938
+ // }
2939
+ return 0;
2940
+ }
2941
+ const requestBody = {
2942
+ fingerprint: this.userFingerprint,
2943
+ app_id: this.config.appId,
2944
+ action: 'increment'
2945
+ };
2946
+ console.log(`🔥 [SUPABASE API] incrementDownloadCount called | Time: ${new Date().toISOString()}`);
2947
+ try {
2948
+ const response = await fetch(`${this.config.supabase.url}/functions/v1/check-download-limit`, {
2949
+ method: 'POST',
2950
+ headers: {
2951
+ 'Content-Type': 'application/json',
2952
+ 'Authorization': `Bearer ${this.config.supabase.anonKey}`
2953
+ },
2954
+ body: JSON.stringify(requestBody)
2955
+ });
2956
+ console.log(`🔥 [SUPABASE API] incrementDownloadCount response: ${response.status}`);
2957
+ if (this.config.options?.debug) {
2958
+ //console.log('🔍 DEBUG: Response status:', response.status);
2959
+ if (!response.ok) {
2960
+ const errorText = await response.text();
2961
+ console.error('🔍 DEBUG: Error response:', errorText);
2962
+ }
2963
+ }
2964
+ if (response.ok) {
2965
+ const data = await response.json();
2966
+ this.supabaseConnectionFailed = false; // Connection successful
2967
+ return data.new_count || 0;
2968
+ }
2969
+ else {
2970
+ // Handle auth errors (401/403) as connection failures
2971
+ if (response.status === 401 || response.status === 403) {
2972
+ console.warn(`Supabase authentication failed: ${response.status} - Invalid anon key`);
2973
+ this.supabaseConnectionFailed = true;
2974
+ }
2975
+ }
2976
+ }
2977
+ catch (error) {
2978
+ this.supabaseConnectionFailed = true; // Mark connection as failed
2979
+ if (this.config.options?.debug) {
2980
+ console.warn('Failed to increment server count, connection failed:', error);
2981
+ }
2982
+ }
2983
+ // Security: Do not fallback to localStorage when server connection fails
2984
+ // This prevents users from bypassing limits by manipulating localStorage
2985
+ return 0;
2986
+ }
2987
+ async checkPremiumStatus(email) {
2988
+ console.log(`🔥 [SUPABASE API] checkPremiumStatus called for email: ${email} | Time: ${new Date().toISOString()}`);
2989
+ try {
2990
+ const response = await fetch(`${this.config.supabase.url}/functions/v1/check-payment-status`, {
2991
+ method: 'POST',
2992
+ headers: {
2993
+ 'Content-Type': 'application/json',
2994
+ 'Authorization': `Bearer ${this.config.supabase.anonKey}`
2995
+ },
2996
+ body: JSON.stringify({
2997
+ email,
2998
+ app_id: this.config.appId
2999
+ })
3000
+ });
3001
+ console.log(`🔥 [SUPABASE API] checkPremiumStatus response: ${response.status}`);
3002
+ if (response.ok) {
3003
+ const data = await response.json();
3004
+ return data.status === 'completed';
3005
+ }
3006
+ }
3007
+ catch (error) {
3008
+ if (this.config.options?.debug) {
3009
+ console.warn('Failed to check premium status:', error);
3010
+ }
3011
+ }
3012
+ return false;
3013
+ }
3014
+ getLocalDownloadCount() {
3015
+ const key = `download_count_${this.config.appId}`;
3016
+ const val = parseInt(localStorage.getItem(key) || '0', 10);
3017
+ return isNaN(val) ? 0 : val;
3018
+ }
3019
+ incrementLocalDownloadCount() {
3020
+ const key = `download_count_${this.config.appId}`;
3021
+ const next = this.getLocalDownloadCount() + 1;
3022
+ localStorage.setItem(key, String(next));
3023
+ return next;
3024
+ }
3025
+ handleError(error) {
3026
+ if (this.config.options?.debug) {
3027
+ console.error('Lead Fast Error:', error);
3028
+ }
3029
+ if (this.config.callbacks?.onError) {
3030
+ this.config.callbacks.onError(error);
3031
+ }
3032
+ else {
3033
+ // Default error handling
3034
+ console.error('Lead Fast:', error.message);
3035
+ }
3036
+ this.emit('error', error);
3037
+ }
3038
+ async checkPaymentStatus() {
3039
+ // Check if user returned from payment
3040
+ const urlParams = new URLSearchParams(window.location.search);
3041
+ if (urlParams.get('payment') === 'success') {
3042
+ // Wait for auth to be ready
3043
+ setTimeout(async () => {
3044
+ if (this.currentUser) {
3045
+ const isPremium = await this.checkPremiumStatus(this.currentUser.email);
3046
+ if (isPremium) {
3047
+ this.showSuccess('Payment Successful!', 'Welcome to premium! You now have unlimited usage.');
3048
+ }
3049
+ else {
3050
+ this.showSuccess('Processing Payment', 'Payment is being processed. Please refresh in a few moments.');
3051
+ }
3052
+ }
3053
+ else {
3054
+ this.showSuccess('Processing Payment', 'Please wait while we verify your payment...');
3055
+ }
3056
+ // Clean up URL
3057
+ const cleanUrl = window.location.href.split('?')[0];
3058
+ window.history.replaceState({}, document.title, cleanUrl);
3059
+ }, 2000);
3060
+ }
3061
+ }
3062
+ }
3063
+ // Export types for consumer use
3064
+ export * from './types.js';
3065
+ //# sourceMappingURL=index.js.map