lucia-sdk 0.9.8 → 0.9.10

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.
Files changed (36) hide show
  1. package/dist/__tests__/features/auto-tracking/registry.test.d.ts +4 -0
  2. package/dist/base/index.d.ts +1 -3
  3. package/dist/core/index.d.ts +1 -6
  4. package/dist/features/auto-tracking/base.d.ts +33 -0
  5. package/dist/{utils → features/auto-tracking}/click-tracker.d.ts +16 -20
  6. package/dist/features/auto-tracking/index.d.ts +5 -0
  7. package/dist/features/auto-tracking/registry.d.ts +54 -0
  8. package/dist/features/auto-tracking/types.d.ts +35 -0
  9. package/dist/{utils/data.d.ts → features/fingerprinting/browser-data.d.ts} +1 -1
  10. package/dist/features/fingerprinting/index.d.ts +1 -0
  11. package/dist/features/web3/index.d.ts +3 -0
  12. package/dist/{utils → features/web3}/solana.d.ts +8 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.es.js +1 -1
  15. package/dist/index.es.js.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/infrastructure/index.d.ts +4 -0
  19. package/dist/package.json +1 -1
  20. package/dist/types.d.ts +96 -5
  21. package/dist/umd/lucia-sdk-0.9.10.min.js +1 -0
  22. package/dist/umd/lucia-sdk-latest.min.js +1 -1
  23. package/package.json +1 -1
  24. package/dist/umd/lucia-sdk-0.9.8.min.js +0 -1
  25. /package/dist/__tests__/{utils → features/auto-tracking}/click-tracker.test.d.ts +0 -0
  26. /package/dist/__tests__/{utils/data.test.d.ts → features/fingerprinting/browser-data.test.d.ts} +0 -0
  27. /package/dist/__tests__/{utils → features/web3}/evm.test.d.ts +0 -0
  28. /package/dist/__tests__/{utils → features/web3}/solana.test.d.ts +0 -0
  29. /package/dist/__tests__/{utils → infrastructure}/http-client.test.d.ts +0 -0
  30. /package/dist/__tests__/{utils → infrastructure}/session.test.d.ts +0 -0
  31. /package/dist/__tests__/{utils → infrastructure}/store.test.d.ts +0 -0
  32. /package/dist/{utils → features/web3}/evm.d.ts +0 -0
  33. /package/dist/{utils → infrastructure}/http-client.d.ts +0 -0
  34. /package/dist/{utils → infrastructure}/logger.d.ts +0 -0
  35. /package/dist/{utils → infrastructure}/session.d.ts +0 -0
  36. /package/dist/{utils → infrastructure}/store.d.ts +0 -0
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
@@ -1,7 +1,5 @@
1
+ import { HttpClient, Logger, Store } from '../infrastructure';
1
2
  import { Config } from '../types';
2
- import HttpClient from '../utils/http-client';
3
- import Logger from '../utils/logger';
4
- import Store from '../utils/store';
5
3
  declare class BaseClass {
6
4
  store: typeof Store.store;
7
5
  dispatch: typeof Store.dispatch;
@@ -1,16 +1,11 @@
1
1
  import BaseClass from '../base';
2
2
  import { ClickEventMetadata } from '../types';
3
3
  declare class LuciaSDK extends BaseClass {
4
- private clickTracker;
5
4
  authenticate(): void;
6
5
  /**
7
6
  * Initializes the SDK with the provided configuration
8
7
  */
9
8
  init(): Promise<void>;
10
- /**
11
- * Initialize automated click tracking if enabled
12
- */
13
- private initAutoTracking;
14
9
  /**
15
10
  * Handle automatically tracked click events
16
11
  */
@@ -58,7 +53,7 @@ declare class LuciaSDK extends BaseClass {
58
53
  */
59
54
  checkMetaMaskConnection(): boolean;
60
55
  /**
61
- * Clean up SDK resources (mainly for testing)
56
+ * Clean up SDK resources
62
57
  */
63
58
  destroy(): void;
64
59
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Base auto-tracker abstract class
3
+ * Provides common lifecycle methods for all auto-trackers
4
+ */
5
+ import { IAutoTracker } from './types';
6
+ import Logger from '../../infrastructure/logger';
7
+ import { Config } from '../../types';
8
+ /**
9
+ * Abstract base class for all auto-trackers
10
+ * Implements common enable/disable/destroy lifecycle
11
+ */
12
+ export declare abstract class BaseAutoTracker<TConfig, TEventData> implements IAutoTracker {
13
+ abstract readonly name: string;
14
+ abstract readonly configKey: string;
15
+ protected enabled: boolean;
16
+ protected sdkConfig: Config;
17
+ protected config: TConfig;
18
+ protected callback: (data: TEventData) => void;
19
+ protected logger: Logger;
20
+ constructor(sdkConfig: Config, config: TConfig, callback: (data: TEventData) => void, logger: Logger);
21
+ /**
22
+ * Attach event listeners - implemented by each tracker
23
+ */
24
+ protected abstract attachListeners(): void;
25
+ /**
26
+ * Detach event listeners - implemented by each tracker
27
+ */
28
+ protected abstract detachListeners(): void;
29
+ enable(): void;
30
+ disable(): void;
31
+ destroy(): void;
32
+ isEnabled(): boolean;
33
+ }
@@ -2,8 +2,10 @@
2
2
  * Automated click tracking implementation
3
3
  * Provides zero-config click tracking with element-level control
4
4
  */
5
- import Logger from './logger';
6
- import { Config } from '../types';
5
+ import { BaseAutoTracker } from './base';
6
+ import { TrackerRegistration } from './types';
7
+ import Logger from '../../infrastructure/logger';
8
+ import { Config } from '../../types';
7
9
  export interface AutoTrackClicksConfig {
8
10
  enabled?: boolean;
9
11
  selectors?: string[];
@@ -20,20 +22,22 @@ export interface ClickEventData {
20
22
  /**
21
23
  * ClickTracker handles automated click event tracking
22
24
  */
23
- export declare class ClickTracker {
24
- private config;
25
- private sdkConfig;
26
- private logger;
25
+ export declare class ClickTracker extends BaseAutoTracker<AutoTrackClicksConfig, ClickEventData> {
26
+ readonly name = "clicks";
27
+ readonly configKey = "autoTrackClicks";
27
28
  private privacyGuard;
28
29
  private debounceTimers;
29
- private trackingCallback;
30
30
  private listenerAttached;
31
31
  private boundHandleClick;
32
32
  constructor(sdkConfig: Config, autoTrackConfig: AutoTrackClicksConfig, trackingCallback: (data: ClickEventData) => void, logger: Logger);
33
33
  /**
34
34
  * Attach the delegated click event listener
35
35
  */
36
- private attachListener;
36
+ protected attachListeners(): void;
37
+ /**
38
+ * Detach the delegated click event listener
39
+ */
40
+ protected detachListeners(): void;
37
41
  /**
38
42
  * Handle click events via delegation
39
43
  */
@@ -85,16 +89,8 @@ export declare class ClickTracker {
85
89
  * Extract metadata from data-lucia-meta-* attributes
86
90
  */
87
91
  private extractMetadata;
88
- /**
89
- * Enable tracking
90
- */
91
- enable(): void;
92
- /**
93
- * Disable tracking
94
- */
95
- disable(): void;
96
- /**
97
- * Cleanup resources
98
- */
99
- destroy(): void;
100
92
  }
93
+ /**
94
+ * Registration object for the click tracker
95
+ */
96
+ export declare const clickTrackerRegistration: TrackerRegistration<AutoTrackClicksConfig, ClickEventData>;
@@ -0,0 +1,5 @@
1
+ export type { IAutoTracker, TrackerRegistration, TrackerFactory, TrackerConfigNormalizer } from './types';
2
+ export { BaseAutoTracker } from './base';
3
+ export { AutoTrackerRegistry, autoTrackerRegistry } from './registry';
4
+ export { ClickTracker, clickTrackerRegistration } from './click-tracker';
5
+ export type { AutoTrackClicksConfig, ClickEventData } from './click-tracker';
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Auto-tracker registry
3
+ * Manages registration and lifecycle of all auto-trackers
4
+ */
5
+ import { IAutoTracker, TrackerRegistration } from './types';
6
+ import Logger from '../../infrastructure/logger';
7
+ import { Config } from '../../types';
8
+ /**
9
+ * Registry for managing auto-tracker plugins
10
+ * Handles registration, initialization, and cleanup of all trackers
11
+ */
12
+ export declare class AutoTrackerRegistry {
13
+ private registrations;
14
+ private activeTrackers;
15
+ private logger;
16
+ /**
17
+ * Register a tracker factory (called at module load time)
18
+ */
19
+ register<TConfig, TEventData>(registration: TrackerRegistration<TConfig, TEventData>): void;
20
+ /**
21
+ * Initialize all configured trackers
22
+ */
23
+ initAll(sdkConfig: Config, callbacks: Record<string, (data: unknown) => void>, logger: Logger): void;
24
+ /**
25
+ * Get a specific tracker by name
26
+ */
27
+ get<T extends IAutoTracker>(name: string): T | undefined;
28
+ /**
29
+ * Enable a specific tracker
30
+ */
31
+ enable(name: string): boolean;
32
+ /**
33
+ * Disable a specific tracker
34
+ */
35
+ disable(name: string): boolean;
36
+ /**
37
+ * Destroy all trackers and clean up
38
+ */
39
+ destroyAll(): void;
40
+ /**
41
+ * List all registered tracker names
42
+ */
43
+ getRegisteredTrackers(): string[];
44
+ /**
45
+ * List all active tracker names
46
+ */
47
+ getActiveTrackers(): string[];
48
+ /**
49
+ * Reset the registry (for testing purposes)
50
+ * Clears active trackers but preserves registrations
51
+ */
52
+ reset(): void;
53
+ }
54
+ export declare const autoTrackerRegistry: AutoTrackerRegistry;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Auto-tracker type definitions
3
+ * Provides interfaces for the plugin-based auto-tracking registry pattern
4
+ */
5
+ import Logger from '../../infrastructure/logger';
6
+ import { Config } from '../../types';
7
+ /**
8
+ * Base interface for all auto-trackers
9
+ */
10
+ export interface IAutoTracker {
11
+ readonly name: string;
12
+ readonly configKey: string;
13
+ enable(): void;
14
+ disable(): void;
15
+ destroy(): void;
16
+ isEnabled(): boolean;
17
+ }
18
+ /**
19
+ * Configuration normalizer - handles boolean | object config
20
+ * Returns null if tracker should not be enabled
21
+ */
22
+ export type TrackerConfigNormalizer<TConfig> = (raw: boolean | TConfig | undefined) => TConfig | null;
23
+ /**
24
+ * Factory function type for creating trackers
25
+ */
26
+ export type TrackerFactory<TConfig, TEventData> = (sdkConfig: Config, trackerConfig: TConfig, callback: (data: TEventData) => void, logger: Logger) => IAutoTracker;
27
+ /**
28
+ * Registration entry for a tracker
29
+ */
30
+ export interface TrackerRegistration<TConfig = unknown, TEventData = unknown> {
31
+ name: string;
32
+ configKey: keyof Config;
33
+ factory: TrackerFactory<TConfig, TEventData>;
34
+ normalizeConfig: TrackerConfigNormalizer<TConfig>;
35
+ }
@@ -1,4 +1,4 @@
1
- import { BrowserData, WalletData } from '../types';
1
+ import { BrowserData, WalletData } from '../../types';
2
2
  /**
3
3
  * Collects static browser and hardware data that's unlikely to change during a session.
4
4
  * This data can be cached for performance optimization.
@@ -0,0 +1 @@
1
+ export { getBrowserData, clearBrowserDataCache, getWalletData, getUtmParams, safeAccess, filterObject, getCanvasFingerprint, isTouchEnabled, getApplePayAvailable, getContrastPreference, getColorGamut, } from './browser-data';
@@ -0,0 +1,3 @@
1
+ export { checkIfEthereumProviderExists, getEthereumAddress, formatEthereumAddress, setupEthereumAccountListeners, getEthereumChainId, getConnectedWalletAddress, isMetaMask, getWalletName, getExtendedProviderInfo, } from './evm';
2
+ export type { ProviderInfo } from './evm';
3
+ export { getConnectedSolanaWallet, getSolanaWalletName } from './solana';
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Type definitions for the Solana wallet objects
3
+ */
1
4
  interface SolanaProvider {
2
5
  isPhantom?: boolean;
3
6
  isConnected: boolean;
@@ -6,7 +9,11 @@ interface SolanaProvider {
6
9
  };
7
10
  connect: (options?: {
8
11
  onlyIfTrusted?: boolean;
9
- }) => Promise<any>;
12
+ }) => Promise<{
13
+ publicKey?: {
14
+ toString: () => string;
15
+ };
16
+ }>;
10
17
  }
11
18
  interface SolflareProvider {
12
19
  isConnected: boolean;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SDK } from './types';
2
- export { getBrowserData, getWalletData, getUtmParams, safeAccess, filterObject, getCanvasFingerprint, isTouchEnabled, getApplePayAvailable, getContrastPreference, getColorGamut, } from './utils/data';
2
+ export { getBrowserData, getWalletData, getUtmParams, safeAccess, filterObject, getCanvasFingerprint, isTouchEnabled, getApplePayAvailable, getContrastPreference, getColorGamut, } from './features/fingerprinting';
3
3
  export declare const __resetInstance: () => void;
4
4
  declare const LuciaSDK: SDK;
5
5
  export default LuciaSDK;
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var o=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),a="0.9.8",s=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new o(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return n(this,arguments,void 0,function(e,t,n){var i,o,a=this;return void 0===n&&(n=!0),r(this,function(r){switch(r.label){case 0:return this.store.config?(i="/api/sdk/init"===e)||this.initComplete?i?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(r,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=r.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return r.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return n(this,void 0,void 0,function(){var e,t=this;return r(this,function(i){switch(i.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,i.label=1;case 1:return i.trys.push([1,,3,4]),e=function(){return n(t,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=r.sent(),t.resolve(n),[3,4];case 3:return i=r.sent(),t.reject(i),[3,4];case 4:return[4,e()];case 5:return r.sent(),[2]}})})},[4,e()];case 2:return i.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,i){return n(this,arguments,void 0,function(e,n,i){var o,s,u,c,l;return void 0===i&&(i=!0),r(this,function(r){switch(r.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),s=n&&"object"==typeof n&&!Array.isArray(n)?n:{payload:n},u=JSON.stringify(t(t({},s),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a},body:JSON.stringify(n)})];case 2:return[4,r.sent().json()];case 3:return[2,r.sent()];case 4:return l=r.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),u={isInitialized:!1,config:null,session:null},c=function(){function e(){}return e.dispatch=function(n){Object.keys(n).forEach(function(r){if(Object.keys(e.store).includes(r)){var o=n[r];e.store[r]="object"==typeof o?Array.isArray(o)?i([],o,!0):t({},o):o}})},e.store=u,e}(),l=function(e){this.store=c.store,this.dispatch=c.dispatch,this.dispatch({config:e}),this.httpClient=new s(this.store),this.logger=new o(this.store)},d=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],h=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i],f=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=i(i([],d,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&h.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),p=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],g=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:p,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=f,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||p;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==p?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||p).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),"text:".concat(this.sanitizeText(s).substring(0,50));var u=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),"path:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),v=new o(c.store);function m(){return n(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),v.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function y(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),v.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function b(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){return window.ethereum?(e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""},Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var k=new o(c.store);function C(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return r.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=r.sent(),k.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return i=r.sent(),k.log("error","Error detecting Solana wallet:",i),[2,null];case 8:return[2]}})})}function T(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,C()];case 1:return(e=r.sent())?(null===(i=window.phantom)||void 0===i?void 0:i.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return W?[2,W]:(e={cores:P(function(){return navigator.hardwareConcurrency}),memory:P(function(){return navigator.deviceMemory}),cpuClass:P(function(){return navigator.cpuClass}),touch:O(),devicePixelRatio:P(function(){return window.devicePixelRatio})},t={width:P(function(){return window.screen.width}),height:P(function(){return window.screen.height}),colorDepth:P(function(){return window.screen.colorDepth}),availHeight:P(function(){return window.screen.availHeight}),availWidth:P(function(){return window.screen.availWidth}),orientation:{type:P(function(){return window.screen.orientation.type}),angle:P(function(){return window.screen.orientation.angle})}},s={language:P(function(){return navigator.language}),encoding:P(function(){return TextDecoder.encoding}),timezone:P(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:P(function(){return navigator.plugins.length}),pluginNames:P(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:j()},[4,D()]);case 1:return s.uniqueHash=r.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,i={navPer:P(function(){return navigator.permissions.webglVersion}),renderedPer:P(function(){return navigator.permissions.RENDERER}),geoPer:P(function(){return navigator.permissions.geolocation})},o={localStorage:P(function(){return!!window.localStorage}),indexedDB:P(function(){return!!window.indexedDB}),openDB:P(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:i,storage:o},[2,a]}})})}function A(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,Promise.all([C(),m(),y(),T(),b()])];case 1:return e=r.sent(),t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&x(a),walletName:i,solWalletName:o}]}})})}function I(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function P(e,t){try{return e()}catch(e){return t}}function x(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function E(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return i=r.sent(),[2,Array.from(new Uint8Array(i)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function D(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,i=120,e.width=n,e.height=i,e.style.width="".concat(n,"px"),e.style.height="".concat(i,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,i),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,i).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,E(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function O(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function j(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(t,")")).matches};return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const _=[];for(let e=0;e<256;++e)_.push((e+256).toString(16).slice(1));let L;const R=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function N(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!L){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");L=crypto.getRandomValues.bind(crypto)}return L(R)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(_[e[t+0]]+_[e[t+1]]+_[e[t+2]]+_[e[t+3]]+"-"+_[e[t+4]]+_[e[t+5]]+"-"+_[e[t+6]]+_[e[t+7]]+"-"+_[e[t+8]]+_[e[t+9]]+"-"+_[e[t+10]]+_[e[t+11]]+_[e[t+12]]+_[e[t+13]]+_[e[t+14]]+_[e[t+15]]).toLowerCase()}(r)}var q="luci_session",B=new o(c.store);function V(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return B.log("error","Error retrieving session data:",e),null}}function z(){var e,t={id:K.randomUUID&&!e?K.randomUUID():N(e),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(t)),t}function Q(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var F=function(i){function o(){var e=null!==i&&i.apply(this,arguments)||this;return e.clickTracker=null,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,i),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return(e=V())||(e=z()),[4,S()];case 1:return t=r.sent(),n=new URL(window.location.href),i=n.searchParams.get("lucia"),[4,A()];case 2:return o=r.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:i,utm:I()},!1)];case 3:return(s=r.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new g(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:i},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return r.sent(),[2]}})})},o.prototype.pageView=function(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=Q(),n=V(),i={page:e,user:{name:H()},session:n},t&&(i.lid=t),[4,this.httpClient.post("/api/sdk/page",i)];case 1:return r.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={tag:e,amount:t,event:i,user:{name:H()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return r.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),o={button:e,user:{name:H()},session:i},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return r.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={walletAddress:e,chainId:t,walletName:i,user:{name:H()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return r.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return n(this,arguments,void 0,function(e,n){var i,o,a;return void 0===n&&(n={}),r(this,function(r){switch(r.label){case 0:return[4,S()];case 1:return i=r.sent(),o=I(),a=V(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:t({timestamp:(new Date).toISOString(),browserData:i,utmParams:o},n)})];case 2:return r.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(l),G=null,Z=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},J=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),G=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},X={init:function(e){if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(G)return G;if(window.__luciaInitPromise)return G=window.__luciaInitPromise;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=n(void 0,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,(t=new F(e)).init()];case 1:return n.sent(),[2,t]}})});return G=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,Z()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackConversion(e,t,i)]}})})},buttonClick:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().sendWalletInfo(e,t,i)]}})})},trackUserAcquisition:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return n(void 0,i([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:a};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),n=null==e?void 0:e.getAttribute("data-api-key");if(n){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(t(t(t({apiKey:n},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}export{J as __resetInstance,X as default,x as filterObject,j as getApplePayAvailable,S as getBrowserData,D as getCanvasFingerprint,U as getColorGamut,M as getContrastPreference,I as getUtmParams,A as getWalletData,O as isTouchEnabled,P as safeAccess};
1
+ function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const n="0.9.10";class i{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new t(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(t){return e(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const e=yield fetch(`${this.baseURL}${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n}});return yield e.json()}catch(e){this.logger.log("error",e)}return null})}post(t,n){return e(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return e(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const t=()=>e(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const e=this.requestQueue.shift();try{const t=yield this.executePost(e.url,e.data,e.fireAndForget);e.resolve(t)}catch(t){e.reject(t)}yield t()});yield t()}finally{this.isProcessingQueue=!1}}})}executePost(t,i){return e(this,arguments,void 0,function*(e,t,i=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const i=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n},body:JSON.stringify(t)});return yield i.json()}catch(e){this.logger.log("error",e)}return null})}}class r{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(r.store).includes(t)){const n=e[t];r.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}r.store={isInitialized:!1,config:null,session:null};const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));let s;const a=new Uint8Array(16);var l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!s){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");s=crypto.getRandomValues.bind(crypto)}return s(a)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(i)}const u="luci_session",d=new t(r.store);function h(){try{const e=sessionStorage.getItem(u);return e?JSON.parse(e):null}catch(e){return d.log("error","Error retrieving session data:",e),null}}function g(){var e;const t={id:l.randomUUID&&!e?l.randomUUID():c(e),timestamp:Date.now()};return sessionStorage.setItem(u,JSON.stringify(t)),t}function f(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function w(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class m{constructor(e){this.store=r.store,this.dispatch=r.dispatch,this.dispatch({config:e}),this.httpClient=new i(this.store),this.logger=new t(this.store)}}class p{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const y=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},v=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],b=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const k=new class{constructor(e=[]){this.sensitiveSelectors=[...v,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&b.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},C=["button","a[href]",'[role="button"]'],T=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class A extends p{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:C,ignore:null!==(s=t.ignore)&&void 0!==s?s:T},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=k}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||C;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==C){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||C).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const S={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new A(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}},I=new t(r.store);function P(){return e(this,void 0,void 0,function*(){try{const{ethereum:e}=window;if(!(null==e?void 0:e.request))return null;const t=yield e.request({method:"eth_accounts"});return t&&t.length>0?t[0]:null}catch(e){return I.log("error","Error checking connected wallet:",e),null}})}function E(){return e(this,void 0,void 0,function*(){try{if(!window.ethereum)return null;if(window.ethereum.isMetaMask)return"MetaMask";if(!window.ethereum.request)return null;return(yield window.ethereum.request({method:"wallet_getName"}))||null}catch(e){return I.log("error","Error getting wallet name:",e),null}})}function O(){return e(this,void 0,void 0,function*(){if(!window.ethereum)return null;const e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""};return Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";const t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),e})}const x=new t(r.store);function W(){return e(this,void 0,void 0,function*(){var e,t,n;try{if(window.solana){if(window.solana.isConnected&&window.solana.publicKey)return window.solana.publicKey.toString()}else if(window.solflare){if(window.solflare.isConnected&&window.solflare.publicKey)return window.solflare.publicKey.toString()}else if(null===(e=window.phantom)||void 0===e?void 0:e.solana)try{if((yield window.phantom.solana.connect({onlyIfTrusted:!0}))&&window.phantom.solana.publicKey)return window.phantom.solana.publicKey.toString()}catch(e){x.log("error","Error silently connecting to Phantom wallet:",e)}const i=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&i.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&i.push(window.SolanaWalletAdapterContext.current);const r=i.find(e=>e.connected&&e.publicKey);return r?r.publicKey.toString():null}catch(e){return x.log("error","Error detecting Solana wallet:",e),null}})}function j(){return e(this,void 0,void 0,function*(){var e,t,n;const i=yield W();if(!i)return null;if(null===(e=window.phantom)||void 0===e?void 0:e.solana)return"Phantom";if(window.solflare)return"Solflare";const r=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&r.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&r.push(window.SolanaWalletAdapterContext.current);const o=r.find(e=>e.connected&&e.publicKey&&e.publicKey.toString()===i);return o?o.name||"Unknown Wallet":null})}function D(){return e(this,void 0,void 0,function*(){if(K)return K;const e={device:{cores:U(()=>navigator.hardwareConcurrency),memory:U(()=>navigator.deviceMemory),cpuClass:U(()=>navigator.cpuClass),touch:N(),devicePixelRatio:U(()=>window.devicePixelRatio)},screen:{width:U(()=>window.screen.width),height:U(()=>window.screen.height),colorDepth:U(()=>window.screen.colorDepth),availHeight:U(()=>window.screen.availHeight),availWidth:U(()=>window.screen.availWidth),orientation:{type:U(()=>window.screen.orientation.type),angle:U(()=>window.screen.orientation.angle)}},browser:{language:U(()=>navigator.language),encoding:U(()=>TextDecoder.encoding),timezone:U(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:U(()=>navigator.plugins.length),pluginNames:U(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:_(),uniqueHash:yield $(),colorGamut:B(),contrastPreference:q()},permissions:{navPer:U(()=>navigator.permissions.webglVersion),renderedPer:U(()=>navigator.permissions.RENDERER),geoPer:U(()=>navigator.permissions.geolocation)},storage:{localStorage:U(()=>!!window.localStorage),indexedDB:U(()=>!!window.indexedDB),openDB:U(()=>window.openDatabase)}};return K=e,e})}function R(){return e(this,void 0,void 0,function*(){const[e,t,n,i,r]=yield Promise.all([W(),P(),E(),j(),O()]);return{walletAddress:t,solanaAddress:e,providerInfo:r&&L(r),walletName:n,solWalletName:i}})}function M(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function U(e,t){try{return e()}catch(e){return t}}function L(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let K=null;function $(){return e(this,void 0,void 0,function*(){try{const t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;t.width=i,t.height=r,t.style.width=`${i}px`,t.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(t){return e(this,void 0,void 0,function*(){const e=(new TextEncoder).encode(t),n=yield crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function N(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function _(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function q(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function B(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}y.register(S);let z=class extends m{authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return e(this,void 0,void 0,function*(){let e=h();e||(e=g());const t=yield D(),n=new URL(window.location.href).searchParams.get("lucia"),i=yield R(),r={id:e.id};e.hash&&(r.hash=e.hash);const o=yield this.httpClient.post("/api/sdk/init",{user:{name:w()},data:t,walletData:i,session:r,redirectHash:n,utm:M()},!1);o&&(o.lid&&localStorage.setItem("lid",o.lid),o.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(u,JSON.stringify(t))}(o.session)),y.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger)})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}userInfo(t,n){return e(this,void 0,void 0,function*(){const e=f(),i=h();t&&localStorage.setItem("luc_uid",t);const r=Object.assign({user:{name:t,userInfo:n},session:i},e&&{lid:e});yield this.httpClient.post("/api/sdk/user",r)})}pageView(t){return e(this,void 0,void 0,function*(){const e=f(),n=h(),i=Object.assign({page:t,user:{name:w()},session:n},e&&{lid:e});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(t,n,i){return e(this,void 0,void 0,function*(){const e=f(),r=h(),o=Object.assign({tag:t,amount:n,event:i,user:{name:w()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(t,n){return e(this,void 0,void 0,function*(){const e=f(),i=h(),r=Object.assign(Object.assign({button:t,user:{name:w()},session:i},e&&{lid:e}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(t,n,i){return e(this,void 0,void 0,function*(){const e=f(),r=h(),o=Object.assign({walletAddress:t,chainId:n,walletName:i,user:{name:w()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/wallet",o)})}trackUserAcquisition(t){return e(this,arguments,void 0,function*(e,t={}){const n=yield D(),i=M(),r=h();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){y.destroyAll()}},V=null;const Q=()=>{const e=V||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},F=()=>{const e=V||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),V=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,y.reset()},H={init:t=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(V)return V;if(window.__luciaInitPromise)return V=window.__luciaInitPromise,V;if(!(null==t?void 0:t.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=e(void 0,void 0,void 0,function*(){const e=new z(t);return yield e.init(),e});return V=n,window.__luciaInitPromise=n,n},userInfo:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield Q()).userInfo(t,n)}),pageView:t=>e(void 0,void 0,void 0,function*(){return(yield Q()).pageView(t)}),trackConversion:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield Q()).trackConversion(t,n,i)}),buttonClick:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield Q()).buttonClick(t,n)}),sendWalletInfo:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield Q()).sendWalletInfo(t,n,i)}),trackUserAcquisition:(t,...n)=>e(void 0,[t,...n],void 0,function*(e,t={}){return(yield Q()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:n};if("undefined"!=typeof window){window.LuciaSDK=H;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");H.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}export{F as __resetInstance,H as default,L as filterObject,_ as getApplePayAvailable,D as getBrowserData,$ as getCanvasFingerprint,B as getColorGamut,q as getContrastPreference,M as getUtmParams,R as getWalletData,N as isTouchEnabled,U as safeAccess};
2
2
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../node_modules/uuid/dist/stringify.js","../node_modules/uuid/dist/rng.js","../node_modules/uuid/dist/native.js","../node_modules/uuid/dist/v4.js"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction _v4(options, buf, offset) {\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n return _v4(options, buf, offset);\n}\nexport default v4;\n"],"names":["byteToHex","i","push","toString","slice","getRandomValues","rnds8","Uint8Array","native","randomUUID","crypto","bind","_v4","options","buf","offset","rnds","random","rng","Error","length","arr","toLowerCase","unsafeStringify"],"mappings":"yhrBACA,MAAMA,EAAY,GAClB,IAAK,IAAIC,EAAI,EAAGA,EAAI,MAAOA,EACvBD,EAAUE,MAAMD,EAAI,KAAOE,SAAS,IAAIC,MAAM,ICHlD,IAAIC,EACJ,MAAMC,EAAQ,IAAIC,WAAW,ICA7B,IAAAC,EAAe,CAAEC,WADoB,oBAAXC,QAA0BA,OAAOD,YAAcC,OAAOD,WAAWE,KAAKD,SCGhG,SAASE,EAAIC,EAASC,EAAKC,GAEvB,MAAMC,GADNH,EAAUA,GAAW,CAAA,GACAI,QAAUJ,EAAQK,SFH5B,WACX,IAAKb,EAAiB,CAClB,GAAsB,oBAAXK,SAA2BA,OAAOL,gBACzC,MAAM,IAAIc,MAAM,4GAEpBd,EAAkBK,OAAOL,gBAAgBM,KAAKD,OAClD,CACA,OAAOL,EAAgBC,EAC3B,CELsDY,GAClD,GAAIF,EAAKI,OAAS,GACd,MAAM,IAAID,MAAM,qCAcpB,OAZAH,EAAK,GAAgB,GAAVA,EAAK,GAAa,GAC7BA,EAAK,GAAgB,GAAVA,EAAK,GAAa,IHL1B,SAAyBK,EAAKN,EAAS,GAC1C,OAAQf,EAAUqB,EAAIN,EAAS,IAC3Bf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,MAAMO,aACrC,CGLWC,CAAgBP,EAC3B,6MACYH,QACJL,EAAOC,aAAuBI,EACvBL,EAAOC,aAEXG,EAAIC","x_google_ignoreList":[0,1,2,3]}
1
+ {"version":3,"file":"index.es.js","sources":["../node_modules/uuid/dist/stringify.js","../node_modules/uuid/dist/rng.js","../node_modules/uuid/dist/native.js","../node_modules/uuid/dist/v4.js"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction _v4(options, buf, offset) {\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n return _v4(options, buf, offset);\n}\nexport default v4;\n"],"names":["byteToHex","i","push","toString","slice","getRandomValues","rnds8","Uint8Array","native","randomUUID","crypto","bind","_v4","options","buf","offset","rnds","random","rng","Error","length","arr","toLowerCase","unsafeStringify"],"mappings":"6jGACA,MAAMA,EAAY,GAClB,IAAK,IAAIC,EAAI,EAAGA,EAAI,MAAOA,EACvBD,EAAUE,MAAMD,EAAI,KAAOE,SAAS,IAAIC,MAAM,ICHlD,IAAIC,EACJ,MAAMC,EAAQ,IAAIC,WAAW,ICA7B,IAAAC,EAAe,CAAEC,WADoB,oBAAXC,QAA0BA,OAAOD,YAAcC,OAAOD,WAAWE,KAAKD,SCGhG,SAASE,EAAIC,EAASC,EAAKC,GAEvB,MAAMC,GADNH,EAAUA,GAAW,CAAA,GACAI,QAAUJ,EAAQK,SFH5B,WACX,IAAKb,EAAiB,CAClB,GAAsB,oBAAXK,SAA2BA,OAAOL,gBACzC,MAAM,IAAIc,MAAM,4GAEpBd,EAAkBK,OAAOL,gBAAgBM,KAAKD,OAClD,CACA,OAAOL,EAAgBC,EAC3B,CELsDY,GAClD,GAAIF,EAAKI,OAAS,GACd,MAAM,IAAID,MAAM,qCAcpB,OAZAH,EAAK,GAAgB,GAAVA,EAAK,GAAa,GAC7BA,EAAK,GAAgB,GAAVA,EAAK,GAAa,IHL1B,SAAyBK,EAAKN,EAAS,GAC1C,OAAQf,EAAUqB,EAAIN,EAAS,IAC3Bf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,MAAMO,aACrC,CGLWC,CAAgBP,EAC3B,iNACYH,cACJL,EAAOC,aAAuBI,EACvBL,EAAOC,aAEXG,EAAIC","x_google_ignoreList":[0,1,2,3]}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var o=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),a="0.9.8",s=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new o(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"},e.prototype.get=function(e){return n(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return n(this,arguments,void 0,function(e,t,n){var i,o,a=this;return void 0===n&&(n=!0),r(this,function(r){switch(r.label){case 0:return this.store.config?(i="/api/sdk/init"===e)||this.initComplete?i?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(r,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=r.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return r.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return n(this,void 0,void 0,function(){var e,t=this;return r(this,function(i){switch(i.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,i.label=1;case 1:return i.trys.push([1,,3,4]),e=function(){return n(t,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=r.sent(),t.resolve(n),[3,4];case 3:return i=r.sent(),t.reject(i),[3,4];case 4:return[4,e()];case 5:return r.sent(),[2]}})})},[4,e()];case 2:return i.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,i){return n(this,arguments,void 0,function(e,n,i){var o,s,u,c,l;return void 0===i&&(i=!0),r(this,function(r){switch(r.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),s=n&&"object"==typeof n&&!Array.isArray(n)?n:{payload:n},u=JSON.stringify(t(t({},s),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":a},body:JSON.stringify(n)})];case 2:return[4,r.sent().json()];case 3:return[2,r.sent()];case 4:return l=r.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),u={isInitialized:!1,config:null,session:null},c=function(){function e(){}return e.dispatch=function(n){Object.keys(n).forEach(function(r){if(Object.keys(e.store).includes(r)){var o=n[r];e.store[r]="object"==typeof o?Array.isArray(o)?i([],o,!0):t({},o):o}})},e.store=u,e}(),l=function(e){this.store=c.store,this.dispatch=c.dispatch,this.dispatch({config:e}),this.httpClient=new s(this.store),this.logger=new o(this.store)},d=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],h=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i],f=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=i(i([],d,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&h.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),p=["button","a[href]",'[role="button"]'],g=["[data-lucia-ignore]",'[data-lucia-track="false"]'],w=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:p,ignore:null!==(a=t.ignore)&&void 0!==a?a:g},this.trackingCallback=n,this.logger=r,this.privacyGuard=f,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||p;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==p?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||p).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),"text:".concat(this.sanitizeText(s).substring(0,50));var u=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),"path:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),v=new o(c.store);function m(){return n(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),v.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function y(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),v.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function b(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){return window.ethereum?(e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""},Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var k=new o(c.store);function C(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return r.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=r.sent(),k.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return i=r.sent(),k.log("error","Error detecting Solana wallet:",i),[2,null];case 8:return[2]}})})}function T(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,C()];case 1:return(e=r.sent())?(null===(i=window.phantom)||void 0===i?void 0:i.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function A(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return D?[2,D]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:O(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,W()]);case 1:return s.uniqueHash=r.sent(),s.colorGamut=M(),s.contrastPreference=j(),n=s,i={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},D=a={device:e,screen:t,browser:n,permissions:i,storage:o},[2,a]}})})}function S(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){switch(r.label){case 0:return[4,Promise.all([C(),m(),y(),T(),b()])];case 1:return e=r.sent(),t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&P(a),walletName:i,solWalletName:o}]}})})}function I(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function P(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function E(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return i=r.sent(),[2,Array.from(new Uint8Array(i)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var D=null;function W(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a;return r(this,function(r){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,i=120,e.width=n,e.height=i,e.style.width="".concat(n,"px"),e.style.height="".concat(i,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,i),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,i).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,E(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function O(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function _(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function j(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(t,")")).matches};return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function M(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const U=[];for(let e=0;e<256;++e)U.push((e+256).toString(16).slice(1));let L;const R=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function N(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!L){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");L=crypto.getRandomValues.bind(crypto)}return L(R)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(U[e[t+0]]+U[e[t+1]]+U[e[t+2]]+U[e[t+3]]+"-"+U[e[t+4]]+U[e[t+5]]+"-"+U[e[t+6]]+U[e[t+7]]+"-"+U[e[t+8]]+U[e[t+9]]+"-"+U[e[t+10]]+U[e[t+11]]+U[e[t+12]]+U[e[t+13]]+U[e[t+14]]+U[e[t+15]]).toLowerCase()}(r)}var B="luci_session",q=new o(c.store);function V(){try{var e=sessionStorage.getItem(B);return e?JSON.parse(e):null}catch(e){return q.log("error","Error retrieving session data:",e),null}}function z(){var e,t={id:K.randomUUID&&!e?K.randomUUID():N(e),timestamp:Date.now()};return sessionStorage.setItem(B,JSON.stringify(t)),t}function Q(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function F(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var H=function(i){function o(){var e=null!==i&&i.apply(this,arguments)||this;return e.clickTracker=null,e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,i),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return n(this,void 0,void 0,function(){var e,t,n,i,o,a,s;return r(this,function(r){switch(r.label){case 0:return(e=V())||(e=z()),[4,A()];case 1:return t=r.sent(),n=new URL(window.location.href),i=n.searchParams.get("lucia"),[4,S()];case 2:return o=r.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:F()},data:t,walletData:o,session:a,redirectHash:i,utm:I()},!1)];case 3:return(s=r.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(B,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new w(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:i},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return r.sent(),[2]}})})},o.prototype.pageView=function(e){return n(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=Q(),n=V(),i={page:e,user:{name:F()},session:n},t&&(i.lid=t),[4,this.httpClient.post("/api/sdk/page",i)];case 1:return r.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={tag:e,amount:t,event:i,user:{name:F()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return r.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return n(this,void 0,void 0,function(){var n,i,o;return r(this,function(r){switch(r.label){case 0:return n=Q(),i=V(),o={button:e,user:{name:F()},session:i},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return r.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,i){return n(this,void 0,void 0,function(){var n,o,a;return r(this,function(r){switch(r.label){case 0:return n=Q(),o=V(),a={walletAddress:e,chainId:t,walletName:i,user:{name:F()},session:o},n&&(a.lid=n),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return r.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return n(this,arguments,void 0,function(e,n){var i,o,a;return void 0===n&&(n={}),r(this,function(r){switch(r.label){case 0:return[4,A()];case 1:return i=r.sent(),o=I(),a=V(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:t({timestamp:(new Date).toISOString(),browserData:i,utmParams:o},n)})];case 2:return r.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(l),G=null,Z=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},J={init:function(e){if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(G)return G;if(window.__luciaInitPromise)return G=window.__luciaInitPromise;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=n(void 0,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,(t=new H(e)).init()];case 1:return n.sent(),[2,t]}})});return G=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,Z()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackConversion(e,t,i)]}})})},buttonClick:function(e,t){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,i){return n(void 0,void 0,void 0,function(){return r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().sendWalletInfo(e,t,i)]}})})},trackUserAcquisition:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return n(void 0,i([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),r(this,function(n){switch(n.label){case 0:return[4,Z()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:a};if("undefined"!=typeof window){window.LuciaSDK=J;var X=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),n=null==e?void 0:e.getAttribute("data-api-key");if(n){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");J.init(t(t(t({apiKey:n},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",X):X()}exports.__resetInstance=function(){var e=G||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),G=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},exports.default=J,exports.filterObject=P,exports.getApplePayAvailable=_,exports.getBrowserData=A,exports.getCanvasFingerprint=W,exports.getColorGamut=M,exports.getContrastPreference=j,exports.getUtmParams=I,exports.getWalletData=S,exports.isTouchEnabled=O,exports.safeAccess=x;
1
+ "use strict";function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}Object.defineProperty(exports,"__esModule",{value:!0}),"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const n="0.9.10";class i{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new t(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(t){return e(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const e=yield fetch(`${this.baseURL}${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n}});return yield e.json()}catch(e){this.logger.log("error",e)}return null})}post(t,n){return e(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return e(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const t=()=>e(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const e=this.requestQueue.shift();try{const t=yield this.executePost(e.url,e.data,e.fireAndForget);e.resolve(t)}catch(t){e.reject(t)}yield t()});yield t()}finally{this.isProcessingQueue=!1}}})}executePost(t,i){return e(this,arguments,void 0,function*(e,t,i=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const i=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":n},body:JSON.stringify(t)});return yield i.json()}catch(e){this.logger.log("error",e)}return null})}}class r{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(r.store).includes(t)){const n=e[t];r.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}r.store={isInitialized:!1,config:null,session:null};const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));let s;const a=new Uint8Array(16);var l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!s){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");s=crypto.getRandomValues.bind(crypto)}return s(a)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(i)}const u="luci_session",d=new t(r.store);function h(){try{const e=sessionStorage.getItem(u);return e?JSON.parse(e):null}catch(e){return d.log("error","Error retrieving session data:",e),null}}function g(){var e;const t={id:l.randomUUID&&!e?l.randomUUID():c(e),timestamp:Date.now()};return sessionStorage.setItem(u,JSON.stringify(t)),t}function f(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function w(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class m{constructor(e){this.store=r.store,this.dispatch=r.dispatch,this.dispatch({config:e}),this.httpClient=new i(this.store),this.logger=new t(this.store)}}class p{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const y=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},v=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],b=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const k=new class{constructor(e=[]){this.sensitiveSelectors=[...v,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&b.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},C=["button","a[href]",'[role="button"]'],T=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class A extends p{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:C,ignore:null!==(s=t.ignore)&&void 0!==s?s:T},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=k}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||C;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==C){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||C).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const S={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new A(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}},I=new t(r.store);function x(){return e(this,void 0,void 0,function*(){try{const{ethereum:e}=window;if(!(null==e?void 0:e.request))return null;const t=yield e.request({method:"eth_accounts"});return t&&t.length>0?t[0]:null}catch(e){return I.log("error","Error checking connected wallet:",e),null}})}function P(){return e(this,void 0,void 0,function*(){try{if(!window.ethereum)return null;if(window.ethereum.isMetaMask)return"MetaMask";if(!window.ethereum.request)return null;return(yield window.ethereum.request({method:"wallet_getName"}))||null}catch(e){return I.log("error","Error getting wallet name:",e),null}})}function E(){return e(this,void 0,void 0,function*(){if(!window.ethereum)return null;const e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""};return Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";const t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),e})}const O=new t(r.store);function j(){return e(this,void 0,void 0,function*(){var e,t,n;try{if(window.solana){if(window.solana.isConnected&&window.solana.publicKey)return window.solana.publicKey.toString()}else if(window.solflare){if(window.solflare.isConnected&&window.solflare.publicKey)return window.solflare.publicKey.toString()}else if(null===(e=window.phantom)||void 0===e?void 0:e.solana)try{if((yield window.phantom.solana.connect({onlyIfTrusted:!0}))&&window.phantom.solana.publicKey)return window.phantom.solana.publicKey.toString()}catch(e){O.log("error","Error silently connecting to Phantom wallet:",e)}const i=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&i.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&i.push(window.SolanaWalletAdapterContext.current);const r=i.find(e=>e.connected&&e.publicKey);return r?r.publicKey.toString():null}catch(e){return O.log("error","Error detecting Solana wallet:",e),null}})}function D(){return e(this,void 0,void 0,function*(){var e,t,n;const i=yield j();if(!i)return null;if(null===(e=window.phantom)||void 0===e?void 0:e.solana)return"Phantom";if(window.solflare)return"Solflare";const r=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&r.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&r.push(window.SolanaWalletAdapterContext.current);const o=r.find(e=>e.connected&&e.publicKey&&e.publicKey.toString()===i);return o?o.name||"Unknown Wallet":null})}function W(){return e(this,void 0,void 0,function*(){if(K)return K;const e={device:{cores:U(()=>navigator.hardwareConcurrency),memory:U(()=>navigator.deviceMemory),cpuClass:U(()=>navigator.cpuClass),touch:_(),devicePixelRatio:U(()=>window.devicePixelRatio)},screen:{width:U(()=>window.screen.width),height:U(()=>window.screen.height),colorDepth:U(()=>window.screen.colorDepth),availHeight:U(()=>window.screen.availHeight),availWidth:U(()=>window.screen.availWidth),orientation:{type:U(()=>window.screen.orientation.type),angle:U(()=>window.screen.orientation.angle)}},browser:{language:U(()=>navigator.language),encoding:U(()=>TextDecoder.encoding),timezone:U(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:U(()=>navigator.plugins.length),pluginNames:U(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:N(),uniqueHash:yield $(),colorGamut:q(),contrastPreference:B()},permissions:{navPer:U(()=>navigator.permissions.webglVersion),renderedPer:U(()=>navigator.permissions.RENDERER),geoPer:U(()=>navigator.permissions.geolocation)},storage:{localStorage:U(()=>!!window.localStorage),indexedDB:U(()=>!!window.indexedDB),openDB:U(()=>window.openDatabase)}};return K=e,e})}function M(){return e(this,void 0,void 0,function*(){const[e,t,n,i,r]=yield Promise.all([j(),x(),P(),D(),E()]);return{walletAddress:t,solanaAddress:e,providerInfo:r&&L(r),walletName:n,solWalletName:i}})}function R(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function U(e,t){try{return e()}catch(e){return t}}function L(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let K=null;function $(){return e(this,void 0,void 0,function*(){try{const t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;t.width=i,t.height=r,t.style.width=`${i}px`,t.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(t){return e(this,void 0,void 0,function*(){const e=(new TextEncoder).encode(t),n=yield crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function _(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function N(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function B(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function q(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}y.register(S);let z=class extends m{authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return e(this,void 0,void 0,function*(){let e=h();e||(e=g());const t=yield W(),n=new URL(window.location.href).searchParams.get("lucia"),i=yield M(),r={id:e.id};e.hash&&(r.hash=e.hash);const o=yield this.httpClient.post("/api/sdk/init",{user:{name:w()},data:t,walletData:i,session:r,redirectHash:n,utm:R()},!1);o&&(o.lid&&localStorage.setItem("lid",o.lid),o.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(u,JSON.stringify(t))}(o.session)),y.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger)})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}userInfo(t,n){return e(this,void 0,void 0,function*(){const e=f(),i=h();t&&localStorage.setItem("luc_uid",t);const r=Object.assign({user:{name:t,userInfo:n},session:i},e&&{lid:e});yield this.httpClient.post("/api/sdk/user",r)})}pageView(t){return e(this,void 0,void 0,function*(){const e=f(),n=h(),i=Object.assign({page:t,user:{name:w()},session:n},e&&{lid:e});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(t,n,i){return e(this,void 0,void 0,function*(){const e=f(),r=h(),o=Object.assign({tag:t,amount:n,event:i,user:{name:w()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(t,n){return e(this,void 0,void 0,function*(){const e=f(),i=h(),r=Object.assign(Object.assign({button:t,user:{name:w()},session:i},e&&{lid:e}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(t,n,i){return e(this,void 0,void 0,function*(){const e=f(),r=h(),o=Object.assign({walletAddress:t,chainId:n,walletName:i,user:{name:w()},session:r},e&&{lid:e});yield this.httpClient.post("/api/sdk/wallet",o)})}trackUserAcquisition(t){return e(this,arguments,void 0,function*(e,t={}){const n=yield W(),i=R(),r=h();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){y.destroyAll()}},V=null;const F=()=>{const e=V||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},Q={init:t=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(V)return V;if(window.__luciaInitPromise)return V=window.__luciaInitPromise,V;if(!(null==t?void 0:t.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=e(void 0,void 0,void 0,function*(){const e=new z(t);return yield e.init(),e});return V=n,window.__luciaInitPromise=n,n},userInfo:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield F()).userInfo(t,n)}),pageView:t=>e(void 0,void 0,void 0,function*(){return(yield F()).pageView(t)}),trackConversion:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield F()).trackConversion(t,n,i)}),buttonClick:(t,n)=>e(void 0,void 0,void 0,function*(){return(yield F()).buttonClick(t,n)}),sendWalletInfo:(t,n,i)=>e(void 0,void 0,void 0,function*(){return(yield F()).sendWalletInfo(t,n,i)}),trackUserAcquisition:(t,...n)=>e(void 0,[t,...n],void 0,function*(e,t={}){return(yield F()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:n};if("undefined"!=typeof window){window.LuciaSDK=Q;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");Q.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}exports.__resetInstance=()=>{const e=V||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),V=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,y.reset()},exports.default=Q,exports.filterObject=L,exports.getApplePayAvailable=N,exports.getBrowserData=W,exports.getCanvasFingerprint=$,exports.getColorGamut=q,exports.getContrastPreference=B,exports.getUtmParams=R,exports.getWalletData=M,exports.isTouchEnabled=_,exports.safeAccess=U;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../node_modules/uuid/dist/stringify.js","../node_modules/uuid/dist/rng.js","../node_modules/uuid/dist/native.js","../node_modules/uuid/dist/v4.js"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction _v4(options, buf, offset) {\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n return _v4(options, buf, offset);\n}\nexport default v4;\n"],"names":["byteToHex","i","push","toString","slice","getRandomValues","rnds8","Uint8Array","native","randomUUID","crypto","bind","_v4","options","buf","offset","rnds","random","rng","Error","length","arr","toLowerCase","unsafeStringify"],"mappings":"6lrBACA,MAAMA,EAAY,GAClB,IAAK,IAAIC,EAAI,EAAGA,EAAI,MAAOA,EACvBD,EAAUE,MAAMD,EAAI,KAAOE,SAAS,IAAIC,MAAM,ICHlD,IAAIC,EACJ,MAAMC,EAAQ,IAAIC,WAAW,ICA7B,IAAAC,EAAe,CAAEC,WADoB,oBAAXC,QAA0BA,OAAOD,YAAcC,OAAOD,WAAWE,KAAKD,SCGhG,SAASE,EAAIC,EAASC,EAAKC,GAEvB,MAAMC,GADNH,EAAUA,GAAW,CAAA,GACAI,QAAUJ,EAAQK,SFH5B,WACX,IAAKb,EAAiB,CAClB,GAAsB,oBAAXK,SAA2BA,OAAOL,gBACzC,MAAM,IAAIc,MAAM,4GAEpBd,EAAkBK,OAAOL,gBAAgBM,KAAKD,OAClD,CACA,OAAOL,EAAgBC,EAC3B,CELsDY,GAClD,GAAIF,EAAKI,OAAS,GACd,MAAM,IAAID,MAAM,qCAcpB,OAZAH,EAAK,GAAgB,GAAVA,EAAK,GAAa,GAC7BA,EAAK,GAAgB,GAAVA,EAAK,GAAa,IHL1B,SAAyBK,EAAKN,EAAS,GAC1C,OAAQf,EAAUqB,EAAIN,EAAS,IAC3Bf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,MAAMO,aACrC,CGLWC,CAAgBP,EAC3B,6MACYH,QACJL,EAAOC,aAAuBI,EACvBL,EAAOC,aAEXG,EAAIC","x_google_ignoreList":[0,1,2,3]}
1
+ {"version":3,"file":"index.js","sources":["../node_modules/uuid/dist/stringify.js","../node_modules/uuid/dist/rng.js","../node_modules/uuid/dist/native.js","../node_modules/uuid/dist/v4.js"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction _v4(options, buf, offset) {\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n return _v4(options, buf, offset);\n}\nexport default v4;\n"],"names":["byteToHex","i","push","toString","slice","getRandomValues","rnds8","Uint8Array","native","randomUUID","crypto","bind","_v4","options","buf","offset","rnds","random","rng","Error","length","arr","toLowerCase","unsafeStringify"],"mappings":"ioGACA,MAAMA,EAAY,GAClB,IAAK,IAAIC,EAAI,EAAGA,EAAI,MAAOA,EACvBD,EAAUE,MAAMD,EAAI,KAAOE,SAAS,IAAIC,MAAM,ICHlD,IAAIC,EACJ,MAAMC,EAAQ,IAAIC,WAAW,ICA7B,IAAAC,EAAe,CAAEC,WADoB,oBAAXC,QAA0BA,OAAOD,YAAcC,OAAOD,WAAWE,KAAKD,SCGhG,SAASE,EAAIC,EAASC,EAAKC,GAEvB,MAAMC,GADNH,EAAUA,GAAW,CAAA,GACAI,QAAUJ,EAAQK,SFH5B,WACX,IAAKb,EAAiB,CAClB,GAAsB,oBAAXK,SAA2BA,OAAOL,gBACzC,MAAM,IAAIc,MAAM,4GAEpBd,EAAkBK,OAAOL,gBAAgBM,KAAKD,OAClD,CACA,OAAOL,EAAgBC,EAC3B,CELsDY,GAClD,GAAIF,EAAKI,OAAS,GACd,MAAM,IAAID,MAAM,qCAcpB,OAZAH,EAAK,GAAgB,GAAVA,EAAK,GAAa,GAC7BA,EAAK,GAAgB,GAAVA,EAAK,GAAa,IHL1B,SAAyBK,EAAKN,EAAS,GAC1C,OAAQf,EAAUqB,EAAIN,EAAS,IAC3Bf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,IACvBf,EAAUqB,EAAIN,EAAS,IACvB,IACAf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,KACvBf,EAAUqB,EAAIN,EAAS,MAAMO,aACrC,CGLWC,CAAgBP,EAC3B,iNACYH,cACJL,EAAOC,aAAuBI,EACvBL,EAAOC,aAEXG,EAAIC","x_google_ignoreList":[0,1,2,3]}
@@ -0,0 +1,4 @@
1
+ export { default as HttpClient } from './http-client';
2
+ export { default as Logger } from './logger';
3
+ export { default as Store } from './store';
4
+ export { getSessionData, storeSessionID, updateSessionFromServer, isSessionValid, generateSessionID, getLidData, getUser, } from './session';
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucia-sdk",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "description": "Lucia JavaScript Library",
6
6
  "repository": {
package/dist/types.d.ts CHANGED
@@ -78,23 +78,114 @@ export interface BrowserData {
78
78
  contrastPreference?: string;
79
79
  };
80
80
  permissions: {
81
- navPer?: any;
82
- renderedPer?: any;
83
- geoPer?: any;
81
+ navPer?: PermissionStatus;
82
+ renderedPer?: PermissionStatus;
83
+ geoPer?: PermissionStatus;
84
84
  };
85
85
  storage: {
86
86
  localStorage?: boolean;
87
87
  indexedDB?: boolean;
88
- openDB?: any;
88
+ openDB?: unknown;
89
89
  };
90
90
  }
91
91
  /**
92
92
  * Wallet data object returned by getWalletData()
93
93
  */
94
94
  export interface WalletData {
95
- providerInfo?: any;
95
+ providerInfo?: Partial<ProviderInfo> | null;
96
96
  walletAddress?: string | null;
97
97
  solanaAddress?: string | null;
98
98
  walletName?: string | null;
99
99
  solWalletName?: string | null;
100
100
  }
101
+ /**
102
+ * Ethereum provider information
103
+ */
104
+ export interface ProviderInfo {
105
+ isMetaMask: boolean;
106
+ isCoinbaseWallet: boolean;
107
+ isWalletConnect: boolean;
108
+ isTrust: boolean;
109
+ isImToken: boolean;
110
+ isBraveWallet: boolean;
111
+ isTokenPocket: boolean;
112
+ isStatus: boolean;
113
+ isTally: boolean;
114
+ isAlphaWallet: boolean;
115
+ isOpera: boolean;
116
+ isCoin98: boolean;
117
+ isMathWallet: boolean;
118
+ isOneInch: boolean;
119
+ isRainbow: boolean;
120
+ isBinanceChainWallet: boolean;
121
+ isFrame: boolean;
122
+ userAgent: string;
123
+ chainId?: string;
124
+ networkVersion?: string;
125
+ name: string;
126
+ isPossiblyGenericInjectedProvider?: boolean;
127
+ }
128
+ /**
129
+ * Session data stored in sessionStorage
130
+ */
131
+ export interface SessionData {
132
+ id: string;
133
+ hash?: string;
134
+ timestamp: number;
135
+ }
136
+ /**
137
+ * User info in API payloads
138
+ */
139
+ export interface UserPayload {
140
+ name: string | null;
141
+ userInfo?: object;
142
+ }
143
+ /**
144
+ * Base API payload structure
145
+ */
146
+ export interface BaseApiPayload {
147
+ user: UserPayload;
148
+ session: SessionData | null;
149
+ lid?: string;
150
+ }
151
+ /**
152
+ * User info API payload
153
+ */
154
+ export interface UserInfoPayload extends BaseApiPayload {
155
+ user: UserPayload & {
156
+ userInfo: object;
157
+ };
158
+ }
159
+ /**
160
+ * Page view API payload
161
+ */
162
+ export interface PageViewPayload extends BaseApiPayload {
163
+ page: string;
164
+ }
165
+ /**
166
+ * Conversion API payload
167
+ */
168
+ export interface ConversionPayload extends BaseApiPayload {
169
+ tag: string;
170
+ amount: number;
171
+ event: object;
172
+ }
173
+ /**
174
+ * Click API payload
175
+ */
176
+ export interface ClickPayload extends BaseApiPayload {
177
+ button: string;
178
+ elementType?: string;
179
+ text?: string;
180
+ href?: string | null;
181
+ meta?: Record<string, string>;
182
+ timestamp?: number;
183
+ }
184
+ /**
185
+ * Wallet API payload
186
+ */
187
+ export interface WalletPayload extends BaseApiPayload {
188
+ walletAddress: string;
189
+ chainId: number | string;
190
+ walletName?: 'Phantom' | 'Metamask';
191
+ }
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LuciaSDK={})}(this,function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const i="0.9.10";class r{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new n(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(e){return t(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const t=yield fetch(`${this.baseURL}${e}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i}});return yield t.json()}catch(e){this.logger.log("error",e)}return null})}post(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return t(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const e=()=>t(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const t=this.requestQueue.shift();try{const e=yield this.executePost(t.url,t.data,t.fireAndForget);t.resolve(e)}catch(e){t.reject(e)}yield e()});yield e()}finally{this.isProcessingQueue=!1}}})}executePost(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(n&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const n=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i},body:JSON.stringify(t)});return yield n.json()}catch(e){this.logger.log("error",e)}return null})}}class o{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(o.store).includes(t)){const n=e[t];o.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}o.store={isInitialized:!1,config:null,session:null};const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));let a;const l=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function u(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(l)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase()}(i)}const d="luci_session",h=new n(o.store);function g(){try{const e=sessionStorage.getItem(d);return e?JSON.parse(e):null}catch(e){return h.log("error","Error retrieving session data:",e),null}}function f(){var e;const t={id:c.randomUUID&&!e?c.randomUUID():u(e),timestamp:Date.now()};return sessionStorage.setItem(d,JSON.stringify(t)),t}function w(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function m(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class p{constructor(e){this.store=o.store,this.dispatch=o.dispatch,this.dispatch({config:e}),this.httpClient=new r(this.store),this.logger=new n(this.store)}}class y{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const v=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},b=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],k=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const C=new class{constructor(e=[]){this.sensitiveSelectors=[...b,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&k.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},T=["button","a[href]",'[role="button"]'],A=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class S extends y{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:T,ignore:null!==(s=t.ignore)&&void 0!==s?s:A},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=C}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||T;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==T){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||A).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const I={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new S(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}},P=new n(o.store);function E(){return t(this,void 0,void 0,function*(){try{const{ethereum:e}=window;if(!(null==e?void 0:e.request))return null;const t=yield e.request({method:"eth_accounts"});return t&&t.length>0?t[0]:null}catch(e){return P.log("error","Error checking connected wallet:",e),null}})}function O(){return t(this,void 0,void 0,function*(){try{if(!window.ethereum)return null;if(window.ethereum.isMetaMask)return"MetaMask";if(!window.ethereum.request)return null;return(yield window.ethereum.request({method:"wallet_getName"}))||null}catch(e){return P.log("error","Error getting wallet name:",e),null}})}function x(){return t(this,void 0,void 0,function*(){if(!window.ethereum)return null;const e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""};return Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";const t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),e})}const j=new n(o.store);function D(){return t(this,void 0,void 0,function*(){var e,t,n;try{if(window.solana){if(window.solana.isConnected&&window.solana.publicKey)return window.solana.publicKey.toString()}else if(window.solflare){if(window.solflare.isConnected&&window.solflare.publicKey)return window.solflare.publicKey.toString()}else if(null===(e=window.phantom)||void 0===e?void 0:e.solana)try{if((yield window.phantom.solana.connect({onlyIfTrusted:!0}))&&window.phantom.solana.publicKey)return window.phantom.solana.publicKey.toString()}catch(e){j.log("error","Error silently connecting to Phantom wallet:",e)}const i=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&i.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&i.push(window.SolanaWalletAdapterContext.current);const r=i.find(e=>e.connected&&e.publicKey);return r?r.publicKey.toString():null}catch(e){return j.log("error","Error detecting Solana wallet:",e),null}})}function W(){return t(this,void 0,void 0,function*(){var e,t,n;const i=yield D();if(!i)return null;if(null===(e=window.phantom)||void 0===e?void 0:e.solana)return"Phantom";if(window.solflare)return"Solflare";const r=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&r.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&r.push(window.SolanaWalletAdapterContext.current);const o=r.find(e=>e.connected&&e.publicKey&&e.publicKey.toString()===i);return o?o.name||"Unknown Wallet":null})}function M(){return t(this,void 0,void 0,function*(){if($)return $;const e={device:{cores:L(()=>navigator.hardwareConcurrency),memory:L(()=>navigator.deviceMemory),cpuClass:L(()=>navigator.cpuClass),touch:N(),devicePixelRatio:L(()=>window.devicePixelRatio)},screen:{width:L(()=>window.screen.width),height:L(()=>window.screen.height),colorDepth:L(()=>window.screen.colorDepth),availHeight:L(()=>window.screen.availHeight),availWidth:L(()=>window.screen.availWidth),orientation:{type:L(()=>window.screen.orientation.type),angle:L(()=>window.screen.orientation.angle)}},browser:{language:L(()=>navigator.language),encoding:L(()=>TextDecoder.encoding),timezone:L(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:L(()=>navigator.plugins.length),pluginNames:L(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:B(),uniqueHash:yield _(),colorGamut:z(),contrastPreference:q()},permissions:{navPer:L(()=>navigator.permissions.webglVersion),renderedPer:L(()=>navigator.permissions.RENDERER),geoPer:L(()=>navigator.permissions.geolocation)},storage:{localStorage:L(()=>!!window.localStorage),indexedDB:L(()=>!!window.indexedDB),openDB:L(()=>window.openDatabase)}};return $=e,e})}function R(){return t(this,void 0,void 0,function*(){const[e,t,n,i,r]=yield Promise.all([D(),E(),O(),W(),x()]);return{walletAddress:t,solanaAddress:e,providerInfo:r&&K(r),walletName:n,solWalletName:i}})}function U(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function L(e,t){try{return e()}catch(e){return t}}function K(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let $=null;function _(){return t(this,void 0,void 0,function*(){try{const e=document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;e.width=i,e.height=r,e.style.width=`${i}px`,e.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(e){return t(this,void 0,void 0,function*(){const t=(new TextEncoder).encode(e),n=yield crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function N(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function B(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function q(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function z(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}v.register(I);let V=class extends p{authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return t(this,void 0,void 0,function*(){let e=g();e||(e=f());const t=yield M(),n=new URL(window.location.href).searchParams.get("lucia"),i=yield R(),r={id:e.id};e.hash&&(r.hash=e.hash);const o=yield this.httpClient.post("/api/sdk/init",{user:{name:m()},data:t,walletData:i,session:r,redirectHash:n,utm:U()},!1);o&&(o.lid&&localStorage.setItem("lid",o.lid),o.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(d,JSON.stringify(t))}(o.session)),v.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger)})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}userInfo(e,n){return t(this,void 0,void 0,function*(){const t=w(),i=g();e&&localStorage.setItem("luc_uid",e);const r=Object.assign({user:{name:e,userInfo:n},session:i},t&&{lid:t});yield this.httpClient.post("/api/sdk/user",r)})}pageView(e){return t(this,void 0,void 0,function*(){const t=w(),n=g(),i=Object.assign({page:e,user:{name:m()},session:n},t&&{lid:t});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(e,n,i){return t(this,void 0,void 0,function*(){const t=w(),r=g(),o=Object.assign({tag:e,amount:n,event:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(e,n){return t(this,void 0,void 0,function*(){const t=w(),i=g(),r=Object.assign(Object.assign({button:e,user:{name:m()},session:i},t&&{lid:t}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(e,n,i){return t(this,void 0,void 0,function*(){const t=w(),r=g(),o=Object.assign({walletAddress:e,chainId:n,walletName:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/wallet",o)})}trackUserAcquisition(e){return t(this,arguments,void 0,function*(e,t={}){const n=yield M(),i=U(),r=g();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){v.destroyAll()}},F=null;const Q=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},H={init:e=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(F)return F;if(window.__luciaInitPromise)return F=window.__luciaInitPromise,F;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=t(void 0,void 0,void 0,function*(){const t=new V(e);return yield t.init(),t});return F=n,window.__luciaInitPromise=n,n},userInfo:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).userInfo(e,n)}),pageView:e=>t(void 0,void 0,void 0,function*(){return(yield Q()).pageView(e)}),trackConversion:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).trackConversion(e,n,i)}),buttonClick:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).buttonClick(e,n)}),sendWalletInfo:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).sendWalletInfo(e,n,i)}),trackUserAcquisition:(e,...n)=>t(void 0,[e,...n],void 0,function*(e,t={}){return(yield Q()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:i};if("undefined"!=typeof window){window.LuciaSDK=H;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");H.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}e.__resetInstance=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),F=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,v.reset()},e.default=H,e.filterObject=K,e.getApplePayAvailable=B,e.getBrowserData=M,e.getCanvasFingerprint=_,e.getColorGamut=z,e.getContrastPreference=q,e.getUtmParams=U,e.getWalletData=R,e.isTouchEnabled=N,e.safeAccess=L,Object.defineProperty(e,"__esModule",{value:!0})});
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LuciaSDK={})}(this,function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),s="0.9.8",u=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new a(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"},e.prototype.get=function(e){return r(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return r(this,arguments,void 0,function(e,t,n){var r,o,a=this;return void 0===n&&(n=!0),i(this,function(i){switch(i.label){case 0:return this.store.config?(r="/api/sdk/init"===e)||this.initComplete?r?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(i,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:i,reject:o,isInit:r}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=i.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return i.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return r(this,void 0,void 0,function(){var e,t=this;return i(this,function(n){switch(n.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,n.label=1;case 1:return n.trys.push([1,,3,4]),e=function(){return r(t,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=i.sent(),t.resolve(n),[3,4];case 3:return r=i.sent(),t.reject(r),[3,4];case 4:return[4,e()];case 5:return i.sent(),[2]}})})},[4,e()];case 2:return n.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,t){return r(this,arguments,void 0,function(e,t,r){var o,a,u,c,l;return void 0===r&&(r=!0),i(this,function(i){switch(i.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(r&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),a=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},u=JSON.stringify(n(n({},a),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s},body:JSON.stringify(t)})];case 2:return[4,i.sent().json()];case 3:return[2,i.sent()];case 4:return l=i.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),c={isInitialized:!1,config:null,session:null},l=function(){function e(){}return e.dispatch=function(t){Object.keys(t).forEach(function(r){if(Object.keys(e.store).includes(r)){var i=t[r];e.store[r]="object"==typeof i?Array.isArray(i)?o([],i,!0):n({},i):i}})},e.store=c,e}(),d=function(e){this.store=l.store,this.dispatch=l.dispatch,this.dispatch({config:e}),this.httpClient=new u(this.store),this.logger=new a(this.store)},h=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],f=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i],p=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=o(o([],h,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&f.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),g=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],v=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:g,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=p,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||g;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==g?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),"text:".concat(this.sanitizeText(s).substring(0,50));var u=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),"path:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),m=new a(l.store);function y(){return r(this,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),m.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function b(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),m.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function k(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){return window.ethereum?(e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""},Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var C=new a(l.store);function T(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return i.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=i.sent(),C.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return r=i.sent(),C.log("error","Error detecting Solana wallet:",r),[2,null];case 8:return[2]}})})}function A(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,T()];case 1:return(e=i.sent())?(null===(r=window.phantom)||void 0===r?void 0:r.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return W?[2,W]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:j(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,O()]);case 1:return s.uniqueHash=i.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,r={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:r,storage:o},[2,a]}})})}function I(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,Promise.all([T(),y(),b(),A(),k()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&E(a),walletName:r,solWalletName:o}]}})})}function P(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function E(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function D(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return r=i.sent(),[2,Array.from(new Uint8Array(r)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function O(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,r=120,e.width=n,e.height=r,e.style.width="".concat(n,"px"),e.style.height="".concat(r,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,r),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,r).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,D(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function j(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function _(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(t,")")).matches};return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const L=[];for(let e=0;e<256;++e)L.push((e+256).toString(16).slice(1));let R;const K=new Uint8Array(16);var N={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function B(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!R){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R(K)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(L[e[t+0]]+L[e[t+1]]+L[e[t+2]]+L[e[t+3]]+"-"+L[e[t+4]]+L[e[t+5]]+"-"+L[e[t+6]]+L[e[t+7]]+"-"+L[e[t+8]]+L[e[t+9]]+"-"+L[e[t+10]]+L[e[t+11]]+L[e[t+12]]+L[e[t+13]]+L[e[t+14]]+L[e[t+15]]).toLowerCase()}(r)}var q="luci_session",V=new a(l.store);function z(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return V.log("error","Error retrieving session data:",e),null}}function Q(){var e,t={id:N.randomUUID&&!e?N.randomUUID():B(e),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(t)),t}function F(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var G=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.clickTracker=null,t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,e),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return(e=z())||(e=Q()),[4,S()];case 1:return t=i.sent(),n=new URL(window.location.href),r=n.searchParams.get("lucia"),[4,I()];case 2:return o=i.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:r,utm:P()},!1)];case 3:return(s=i.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new v(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:r},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return i.sent(),[2]}})})},o.prototype.pageView=function(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=F(),n=z(),r={page:e,user:{name:H()},session:n},t&&(r.lid=t),[4,this.httpClient.post("/api/sdk/page",r)];case 1:return i.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={tag:e,amount:t,event:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return i.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),o={button:e,user:{name:H()},session:r},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return i.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={walletAddress:e,chainId:t,walletName:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return i.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return r(this,arguments,void 0,function(e,t){var r,o,a;return void 0===t&&(t={}),i(this,function(i){switch(i.label){case 0:return[4,S()];case 1:return r=i.sent(),o=P(),a=z(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:n({timestamp:(new Date).toISOString(),browserData:r,utmParams:o},t)})];case 2:return i.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(d),Z=null,J=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},X={init:function(e){if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(Z)return Z;if(window.__luciaInitPromise)return Z=window.__luciaInitPromise;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=r(void 0,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,(t=new G(e)).init()];case 1:return n.sent(),[2,t]}})});return Z=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return r(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,J()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().trackConversion(e,t,n)]}})})},buttonClick:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().sendWalletInfo(e,t,n)]}})})},trackUserAcquisition:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return r(void 0,o([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:s};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(t){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(n(n(n({apiKey:t},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}e.__resetInstance=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),Z=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},e.default=X,e.filterObject=E,e.getApplePayAvailable=_,e.getBrowserData=S,e.getCanvasFingerprint=O,e.getColorGamut=U,e.getContrastPreference=M,e.getUtmParams=P,e.getWalletData=I,e.isTouchEnabled=j,e.safeAccess=x,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LuciaSDK={})}(this,function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e){this.store=e}log(e,...t){var n;(null===(n=this.store.config)||void 0===n?void 0:n.debug)&&console[e](t)}}const i="0.9.10";class r{constructor(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new n(this.store)}getBaseURL(){const{config:e}=this.store;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"}get(e){return t(this,void 0,void 0,function*(){if(!this.store.config)return this.logger.log("error","Config is not set"),null;try{const t=yield fetch(`${this.baseURL}${e}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i}});return yield t.json()}catch(e){this.logger.log("error",e)}return null})}post(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;const i="/api/sdk/init"===e;if(!i&&!this.initComplete)return new Promise((r,o)=>{this.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:r,reject:o,isInit:i}),this.processQueue()});if(i){const i=yield this.executePost(e,t,n);return this.initComplete=!0,yield this.processQueue(),i}return this.executePost(e,t,n)})}processQueue(){return t(this,void 0,void 0,function*(){if(!this.isProcessingQueue&&this.initComplete&&0!==this.requestQueue.length){this.isProcessingQueue=!0;try{const e=()=>t(this,void 0,void 0,function*(){if(0===this.requestQueue.length)return;const t=this.requestQueue.shift();try{const e=yield this.executePost(t.url,t.data,t.fireAndForget);t.resolve(e)}catch(e){t.reject(e)}yield e()});yield e()}finally{this.isProcessingQueue=!1}}})}executePost(e,n){return t(this,arguments,void 0,function*(e,t,n=!0){if(!this.store.config)return this.logger.log("error","Config is not set"),null;if(n&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{const n=`${this.baseURL}${e}`,i=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},r=JSON.stringify(Object.assign(Object.assign({},i),{_apiKey:this.store.config.apiKey})),o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return null}try{const n=yield fetch(`${this.baseURL}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":i},body:JSON.stringify(t)});return yield n.json()}catch(e){this.logger.log("error",e)}return null})}}class o{static dispatch(e){Object.keys(e).forEach(t=>{if(Object.keys(o.store).includes(t)){const n=e[t];o.store[t]="object"==typeof n?Array.isArray(n)?[...n]:Object.assign({},n):n}})}}o.store={isInitialized:!1,config:null,session:null};const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));let a;const l=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function u(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(l)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase()}(i)}const d="luci_session",h=new n(o.store);function g(){try{const e=sessionStorage.getItem(d);return e?JSON.parse(e):null}catch(e){return h.log("error","Error retrieving session data:",e),null}}function f(){var e;const t={id:c.randomUUID&&!e?c.randomUUID():u(e),timestamp:Date.now()};return sessionStorage.setItem(d,JSON.stringify(t)),t}function w(){const e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function m(){const e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}class p{constructor(e){this.store=o.store,this.dispatch=o.dispatch,this.dispatch({config:e}),this.httpClient=new r(this.store),this.logger=new n(this.store)}}class y{constructor(e,t,n,i){this.enabled=!1,this.sdkConfig=e,this.config=t,this.callback=n,this.logger=i}enable(){this.enabled||(this.enabled=!0,this.attachListeners(),this.logger.log("log",`${this.name}: Enabled`))}disable(){this.enabled&&(this.enabled=!1,this.logger.log("log",`${this.name}: Disabled`))}destroy(){this.disable(),this.detachListeners(),this.logger.log("log",`${this.name}: Destroyed`)}isEnabled(){return this.enabled}}const v=new class{constructor(){this.registrations=new Map,this.activeTrackers=new Map,this.logger=null}register(e){this.registrations.set(e.name,e)}initAll(e,t,n){this.logger=n;for(const[i,r]of this.registrations){const o=e[r.configKey],s=r.normalizeConfig(o);if(null===s)continue;const a=t[i];if(a)try{const t=r.factory(e,s,a,n);this.activeTrackers.set(i,t),t.enable(),n.log("log",`AutoTrackerRegistry: Initialized ${i}`)}catch(e){n.log("error",`AutoTrackerRegistry: Failed to initialize ${i}`,e)}else n.log("warn",`AutoTrackerRegistry: No callback registered for ${i}`)}}get(e){return this.activeTrackers.get(e)}enable(e){const t=this.activeTrackers.get(e);return!!t&&(t.enable(),!0)}disable(e){const t=this.activeTrackers.get(e);return!!t&&(t.disable(),!0)}destroyAll(){var e;for(const[t,n]of this.activeTrackers)try{n.destroy()}catch(n){null===(e=this.logger)||void 0===e||e.log("error",`AutoTrackerRegistry: Error destroying ${t}`,n)}this.activeTrackers.clear()}getRegisteredTrackers(){return Array.from(this.registrations.keys())}getActiveTrackers(){return Array.from(this.activeTrackers.keys())}reset(){this.destroyAll(),this.logger=null}},b=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],k=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i];const C=new class{constructor(e=[]){this.sensitiveSelectors=[...b,...e]}isSensitive(e){if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;let t=e.parentElement;for(;t;){const e=t;if(this.sensitiveSelectors.some(t=>{try{return e.matches(t)}catch(e){return!1}}))return!0;t=t.parentElement}return!1}containsSensitiveData(e){return!!e&&k.some(t=>t.test(e))}sanitizeText(e){if(!e)return"";let t=e;return t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****"),t=t.replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****"),t=t.replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2"),t}},T=["button","a[href]",'[role="button"]'],A=["[data-lucia-ignore]",'[data-lucia-track="false"]'];class S extends y{constructor(e,t,n,i){var r,o,s;super(e,{enabled:null===(r=t.enabled)||void 0===r||r,selectors:null!==(o=t.selectors)&&void 0!==o?o:T,ignore:null!==(s=t.ignore)&&void 0!==s?s:A},n,i),this.name="clicks",this.configKey="autoTrackClicks",this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.privacyGuard=C}attachListeners(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))}detachListeners(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null}handleClick(e){if(!this.enabled)return;const t=e.target;if(!t)return;const n=this.findTrackableElement(t);if(!n)return;if(this.shouldIgnore(n))return void this.logger.log("log","ClickTracker: Element ignored",n);if(this.privacyGuard.isSensitive(n))return void this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);if(this.isDebounced(n))return void this.logger.log("log","ClickTracker: Click debounced",n);const i=this.extractTrackingData(n);i&&(this.logger.log("log","ClickTracker: Tracking click",i),this.callback(i))}findTrackableElement(e){const t=this.config.selectors||T;try{const n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n)){if(this.config.selectors&&this.config.selectors!==T){return t.some(e=>{try{return n.matches(e)}catch(e){return!1}})?n:null}return n}const i=t.join(", "),r=e.closest(i);return r&&r!==document.body&&document.body.contains(r)?r:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);let n=e;for(;n&&n!==document.body;){if(this.isTrackable(n))return n;n=n.parentElement}return null}}isTrackable(e){return(this.config.selectors||T).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid selector "${t}"`,e),!1}})}shouldIgnore(e){return(this.config.ignore||A).some(t=>{try{return e.matches(t)}catch(e){return this.logger.log("warn",`ClickTracker: Invalid ignore selector "${t}"`,e),!1}})}isDebounced(e){const t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)}cleanupDebounceTimers(){const e=Date.now();Array.from(this.debounceTimers.entries()).forEach(([t,n])=>{e-n>1e3&&this.debounceTimers.delete(t)})}extractTrackingData(e){var t;const n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;const i={button:n,elementType:this.getElementType(e),timestamp:Date.now()},r=null===(t=e.textContent)||void 0===t?void 0:t.trim();r&&(this.privacyGuard.containsSensitiveData(r)||(i.text=this.sanitizeText(r))),"a"===e.tagName.toLowerCase()?i.href=e.getAttribute("href"):i.href=null;const o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(i.meta=o),i}getElementIdentifier(e){var t;const n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;const i=e.getAttribute("id");if(i)return i;const r=e.getAttribute("name");if(r)return r;const o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){const t=e.getAttribute("href");if(t)return`link:${t}`}const s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),`text:${this.sanitizeText(s).substring(0,50)}`;const a=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),`path:${a}`}getElementType(e){const t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";const n=e.getAttribute("role");return n||t}sanitizeText(e){return e.trim().replace(/\s+/g," ").substring(0,100)}generateCSSPath(e){const t=[];let n=e;for(;n&&n!==document.body&&t.length<5;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}const i=n.getAttribute("class");if(i){const t=i.trim().split(/\s+/).slice(0,2);t.length>0&&(e+=`.${t.join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}extractMetadata(e){const t={},{attributes:n}=e;return Array.from(n).forEach(e=>{if(e.name.startsWith("data-lucia-meta-")){const n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,e=>e[1].toUpperCase());t[n]=e.value}}),Object.keys(t).length>0?t:null}}const I={name:"clicks",configKey:"autoTrackClicks",factory:(e,t,n,i)=>new S(e,t,n,i),normalizeConfig:function(e){return void 0===e||!1===e?null:!0===e?{enabled:!0}:!1===e.enabled?null:e}},P=new n(o.store);function E(){return t(this,void 0,void 0,function*(){try{const{ethereum:e}=window;if(!(null==e?void 0:e.request))return null;const t=yield e.request({method:"eth_accounts"});return t&&t.length>0?t[0]:null}catch(e){return P.log("error","Error checking connected wallet:",e),null}})}function O(){return t(this,void 0,void 0,function*(){try{if(!window.ethereum)return null;if(window.ethereum.isMetaMask)return"MetaMask";if(!window.ethereum.request)return null;return(yield window.ethereum.request({method:"wallet_getName"}))||null}catch(e){return P.log("error","Error getting wallet name:",e),null}})}function x(){return t(this,void 0,void 0,function*(){if(!window.ethereum)return null;const e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""};return Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";const t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),e})}const j=new n(o.store);function D(){return t(this,void 0,void 0,function*(){var e,t,n;try{if(window.solana){if(window.solana.isConnected&&window.solana.publicKey)return window.solana.publicKey.toString()}else if(window.solflare){if(window.solflare.isConnected&&window.solflare.publicKey)return window.solflare.publicKey.toString()}else if(null===(e=window.phantom)||void 0===e?void 0:e.solana)try{if((yield window.phantom.solana.connect({onlyIfTrusted:!0}))&&window.phantom.solana.publicKey)return window.phantom.solana.publicKey.toString()}catch(e){j.log("error","Error silently connecting to Phantom wallet:",e)}const i=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&i.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&i.push(window.SolanaWalletAdapterContext.current);const r=i.find(e=>e.connected&&e.publicKey);return r?r.publicKey.toString():null}catch(e){return j.log("error","Error detecting Solana wallet:",e),null}})}function W(){return t(this,void 0,void 0,function*(){var e,t,n;const i=yield D();if(!i)return null;if(null===(e=window.phantom)||void 0===e?void 0:e.solana)return"Phantom";if(window.solflare)return"Solflare";const r=[];(null===(t=window.walletAdapterNetwork)||void 0===t?void 0:t.adapters)&&r.push(...window.walletAdapterNetwork.adapters),(null===(n=window.SolanaWalletAdapterContext)||void 0===n?void 0:n.current)&&r.push(window.SolanaWalletAdapterContext.current);const o=r.find(e=>e.connected&&e.publicKey&&e.publicKey.toString()===i);return o?o.name||"Unknown Wallet":null})}function M(){return t(this,void 0,void 0,function*(){if($)return $;const e={device:{cores:L(()=>navigator.hardwareConcurrency),memory:L(()=>navigator.deviceMemory),cpuClass:L(()=>navigator.cpuClass),touch:N(),devicePixelRatio:L(()=>window.devicePixelRatio)},screen:{width:L(()=>window.screen.width),height:L(()=>window.screen.height),colorDepth:L(()=>window.screen.colorDepth),availHeight:L(()=>window.screen.availHeight),availWidth:L(()=>window.screen.availWidth),orientation:{type:L(()=>window.screen.orientation.type),angle:L(()=>window.screen.orientation.angle)}},browser:{language:L(()=>navigator.language),encoding:L(()=>TextDecoder.encoding),timezone:L(()=>-(new Date).getTimezoneOffset()/60),pluginsLength:L(()=>navigator.plugins.length),pluginNames:L(()=>Array.from(navigator.plugins,e=>e.name)),applePayAvailable:B(),uniqueHash:yield _(),colorGamut:z(),contrastPreference:q()},permissions:{navPer:L(()=>navigator.permissions.webglVersion),renderedPer:L(()=>navigator.permissions.RENDERER),geoPer:L(()=>navigator.permissions.geolocation)},storage:{localStorage:L(()=>!!window.localStorage),indexedDB:L(()=>!!window.indexedDB),openDB:L(()=>window.openDatabase)}};return $=e,e})}function R(){return t(this,void 0,void 0,function*(){const[e,t,n,i,r]=yield Promise.all([D(),E(),O(),W(),x()]);return{walletAddress:t,solanaAddress:e,providerInfo:r&&K(r),walletName:n,solWalletName:i}})}function U(){const e=new URL(window.location.href).searchParams,t={};return e.forEach((e,n)=>{(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function L(e,t){try{return e()}catch(e){return t}}function K(e){const t={};return Object.keys(e).forEach(n=>{const i=n;e[i]&&(t[i]=e[i])}),t}let $=null;function _(){return t(this,void 0,void 0,function*(){try{const e=document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)return;const i=200,r=120;e.width=i,e.height=r,e.style.width=`${i}px`,e.style.height=`${r}px`,n.fillStyle="#ffffff",n.fillRect(0,0,i,r),n.fillStyle="#ff00ff",n.fillRect(10,10,100,100),n.fillStyle="#00ffff",n.beginPath(),n.arc(150,50,40,0,2*Math.PI,!0),n.fill();const{data:o}=n.getImageData(0,0,i,r);return function(e){return t(this,void 0,void 0,function*(){const t=(new TextEncoder).encode(e),n=yield crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")})}([[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(([e,t])=>{const n=4*(t*i+e);return`${o[n]},${o[n+1]},${o[n+2]},${o[n+3]};`}).join(""))}catch(e){return}})}function N(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function B(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function q(){try{const{matchMedia:e}=window,t=t=>e(`(prefers-contrast: ${t})`).matches;return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function z(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(e=>window.matchMedia(`(color-gamut: ${e})`).matches)}catch(e){return[]}}v.register(I);let V=class extends p{authenticate(){this.httpClient.post("/api/key/auth",{})}init(){return t(this,void 0,void 0,function*(){let e=g();e||(e=f());const t=yield M(),n=new URL(window.location.href).searchParams.get("lucia"),i=yield R(),r={id:e.id};e.hash&&(r.hash=e.hash);const o=yield this.httpClient.post("/api/sdk/init",{user:{name:m()},data:t,walletData:i,session:r,redirectHash:n,utm:U()},!1);o&&(o.lid&&localStorage.setItem("lid",o.lid),o.session&&function(e){const t={id:e.id,hash:e.hash,timestamp:Date.now()};sessionStorage.setItem(d,JSON.stringify(t))}(o.session)),v.initAll(this.store.config,{clicks:this.handleAutoTrackedClick.bind(this)},this.logger)})}handleAutoTrackedClick(e){const t=e,n={elementType:t.elementType,text:t.text,href:t.href,meta:t.meta};this.buttonClick(t.button,n)}userInfo(e,n){return t(this,void 0,void 0,function*(){const t=w(),i=g();e&&localStorage.setItem("luc_uid",e);const r=Object.assign({user:{name:e,userInfo:n},session:i},t&&{lid:t});yield this.httpClient.post("/api/sdk/user",r)})}pageView(e){return t(this,void 0,void 0,function*(){const t=w(),n=g(),i=Object.assign({page:e,user:{name:m()},session:n},t&&{lid:t});yield this.httpClient.post("/api/sdk/page",i)})}trackConversion(e,n,i){return t(this,void 0,void 0,function*(){const t=w(),r=g(),o=Object.assign({tag:e,amount:n,event:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/conversion",o)})}buttonClick(e,n){return t(this,void 0,void 0,function*(){const t=w(),i=g(),r=Object.assign(Object.assign({button:e,user:{name:m()},session:i},t&&{lid:t}),n&&Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.elementType&&{elementType:n.elementType}),n.text&&{text:n.text}),void 0!==n.href&&{href:n.href}),n.meta&&{meta:n.meta}),{timestamp:Date.now()}));yield this.httpClient.post("/api/sdk/click",r)})}sendWalletInfo(e,n,i){return t(this,void 0,void 0,function*(){const t=w(),r=g(),o=Object.assign({walletAddress:e,chainId:n,walletName:i,user:{name:m()},session:r},t&&{lid:t});yield this.httpClient.post("/api/sdk/wallet",o)})}trackUserAcquisition(e){return t(this,arguments,void 0,function*(e,t={}){const n=yield M(),i=U(),r=g();yield this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:r,data:Object.assign({timestamp:(new Date).toISOString(),browserData:n,utmParams:i},t)})})}checkMetaMaskConnection(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))}destroy(){v.destroyAll()}},F=null;const Q=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},H={init:e=>{if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(F)return F;if(window.__luciaInitPromise)return F=window.__luciaInitPromise,F;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));const n=t(void 0,void 0,void 0,function*(){const t=new V(e);return yield t.init(),t});return F=n,window.__luciaInitPromise=n,n},userInfo:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).userInfo(e,n)}),pageView:e=>t(void 0,void 0,void 0,function*(){return(yield Q()).pageView(e)}),trackConversion:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).trackConversion(e,n,i)}),buttonClick:(e,n)=>t(void 0,void 0,void 0,function*(){return(yield Q()).buttonClick(e,n)}),sendWalletInfo:(e,n,i)=>t(void 0,void 0,void 0,function*(){return(yield Q()).sendWalletInfo(e,n,i)}),trackUserAcquisition:(e,...n)=>t(void 0,[e,...n],void 0,function*(e,t={}){return(yield Q()).trackUserAcquisition(e,t)}),checkMetaMaskConnection:()=>{var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:i};if("undefined"!=typeof window){window.LuciaSDK=H;const e=()=>{const e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(!t)return;const n=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),r=e.getAttribute("data-track-selectors");H.init(Object.assign(Object.assign(Object.assign({apiKey:t},n&&{debugURL:n}),"true"===i&&{autoTrackClicks:!r||{enabled:!0,selectors:r.split(",").map(e=>e.trim())}}),"false"===i&&{autoTrackClicks:!1})).catch(e=>console.error("LuciaSDK auto-init failed:",e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}e.__resetInstance=()=>{const e=F||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(e=>e.destroy()).catch(()=>{}),F=null,"undefined"!=typeof window&&delete window.__luciaInitPromise,v.reset()},e.default=H,e.filterObject=K,e.getApplePayAvailable=B,e.getBrowserData=M,e.getCanvasFingerprint=_,e.getColorGamut=z,e.getContrastPreference=q,e.getUtmParams=U,e.getWalletData=R,e.isTouchEnabled=N,e.safeAccess=L,Object.defineProperty(e,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucia-sdk",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "description": "Lucia JavaScript Library",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LuciaSDK={})}(this,function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function o(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a=function(){function e(e){this.store=e}return e.prototype.log=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(null===(t=this.store.config)||void 0===t?void 0:t.debug)&&console[e](n)},e}(),s="0.9.8",u=function(){function e(e){this.requestQueue=[],this.isProcessingQueue=!1,this.initComplete=!1,this.store=e,this.baseURL=this.getBaseURL(),this.logger=new a(this.store)}return e.prototype.getBaseURL=function(){var e=this.store.config;return(null==e?void 0:e.debugURL)?e.debugURL:(null==e?void 0:e.testENV)?"http://52.22.177.60/fk":"https://api.clickinsights.xyz"},e.prototype.get=function(e){return r(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"GET",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s}})];case 2:return[4,n.sent().json()];case 3:return[2,n.sent()];case 4:return t=n.sent(),this.logger.log("error",t),[3,5];case 5:return[2,null]}})})},e.prototype.post=function(e,t){return r(this,arguments,void 0,function(e,t,n){var r,o,a=this;return void 0===n&&(n=!0),i(this,function(i){switch(i.label){case 0:return this.store.config?(r="/api/sdk/init"===e)||this.initComplete?r?[4,this.executePost(e,t,n)]:[3,3]:[2,new Promise(function(i,o){a.requestQueue.push({url:e,data:t,fireAndForget:n,resolve:i,reject:o,isInit:r}),a.processQueue()})]:(this.logger.log("error","Config is not set"),[2,null]);case 1:return o=i.sent(),this.initComplete=!0,[4,this.processQueue()];case 2:return i.sent(),[2,o];case 3:return[2,this.executePost(e,t,n)]}})})},e.prototype.processQueue=function(){return r(this,void 0,void 0,function(){var e,t=this;return i(this,function(n){switch(n.label){case 0:if(this.isProcessingQueue||!this.initComplete||0===this.requestQueue.length)return[2];this.isProcessingQueue=!0,n.label=1;case 1:return n.trys.push([1,,3,4]),e=function(){return r(t,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:if(0===this.requestQueue.length)return[2];t=this.requestQueue.shift(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.executePost(t.url,t.data,t.fireAndForget)];case 2:return n=i.sent(),t.resolve(n),[3,4];case 3:return r=i.sent(),t.reject(r),[3,4];case 4:return[4,e()];case 5:return i.sent(),[2]}})})},[4,e()];case 2:return n.sent(),[3,4];case 3:return this.isProcessingQueue=!1,[7];case 4:return[2]}})})},e.prototype.executePost=function(e,t){return r(this,arguments,void 0,function(e,t,r){var o,a,u,c,l;return void 0===r&&(r=!0),i(this,function(i){switch(i.label){case 0:if(!this.store.config)return this.logger.log("error","Config is not set"),[2,null];if(r&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){try{o="".concat(this.baseURL).concat(e),a=t&&"object"==typeof t&&!Array.isArray(t)?t:{payload:t},u=JSON.stringify(n(n({},a),{_apiKey:this.store.config.apiKey})),c=new Blob([u],{type:"application/json"}),navigator.sendBeacon(o,c)||this.logger.log("error","sendBeacon failed")}catch(e){this.logger.log("error",e)}return[2,null]}i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.store.config.apiKey,"SDK-VERSION":s},body:JSON.stringify(t)})];case 2:return[4,i.sent().json()];case 3:return[2,i.sent()];case 4:return l=i.sent(),this.logger.log("error",l),[3,5];case 5:return[2,null]}})})},e}(),c={isInitialized:!1,config:null,session:null},l=function(){function e(){}return e.dispatch=function(t){Object.keys(t).forEach(function(r){if(Object.keys(e.store).includes(r)){var i=t[r];e.store[r]="object"==typeof i?Array.isArray(i)?o([],i,!0):n({},i):i}})},e.store=c,e}(),d=function(e){this.store=l.store,this.dispatch=l.dispatch,this.dispatch({config:e}),this.httpClient=new u(this.store),this.logger=new a(this.store)},h=['input[type="password"]','input[type="text"][autocomplete*="cc-"]','input[type="text"][autocomplete*="card"]','input[type="text"][name*="card"]','input[type="text"][name*="cvv"]','input[type="text"][name*="cvc"]','input[name*="ssn"]','input[name*="social"]',"[data-sensitive]","[data-private]"],f=[/\b\d{3}-\d{2}-\d{4}\b/,/\b\d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4}\b/,/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i],p=new(function(){function e(e){void 0===e&&(e=[]),this.sensitiveSelectors=o(o([],h,!0),e,!0)}return e.prototype.isSensitive=function(e){if(this.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return!0;for(var t=e.parentElement,n=function(){var e=t;if(r.sensitiveSelectors.some(function(t){try{return e.matches(t)}catch(e){return!1}}))return{value:!0};t=t.parentElement},r=this;t;){var i=n();if("object"==typeof i)return i.value}return!1},e.prototype.containsSensitiveData=function(e){return!!e&&f.some(function(t){return t.test(e)})},e.prototype.sanitizeText=function(e){if(!e)return"";var t=e;return t=(t=(t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***-**-****")).replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,"****-****-****-****")).replace(/\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})\b/gi,"***@$2")},e}()),g=["button","a[href]",'[role="button"]'],w=["[data-lucia-ignore]",'[data-lucia-track="false"]'],v=function(){function e(e,t,n,r){var i,o,a;this.debounceTimers=new Map,this.listenerAttached=!1,this.boundHandleClick=null,this.sdkConfig=e,this.config={enabled:null===(i=t.enabled)||void 0===i||i,selectors:null!==(o=t.selectors)&&void 0!==o?o:g,ignore:null!==(a=t.ignore)&&void 0!==a?a:w},this.trackingCallback=n,this.logger=r,this.privacyGuard=p,this.config.enabled&&this.attachListener()}return e.prototype.attachListener=function(){this.listenerAttached||("undefined"!=typeof document?(this.boundHandleClick=this.handleClick.bind(this),document.addEventListener("click",this.boundHandleClick,{passive:!0,capture:!1}),this.listenerAttached=!0,this.logger.log("log","ClickTracker: Delegated click listener attached")):this.logger.log("warn","ClickTracker: document not available, cannot attach listener"))},e.prototype.handleClick=function(e){if(this.config.enabled){var t=e.target;if(t){var n=this.findTrackableElement(t);if(n)if(this.shouldIgnore(n))this.logger.log("log","ClickTracker: Element ignored",n);else if(this.privacyGuard.isSensitive(n))this.logger.log("warn","ClickTracker: Sensitive element not tracked",n);else if(this.isDebounced(n))this.logger.log("log","ClickTracker: Click debounced",n);else{var r=this.extractTrackingData(n);r&&(this.logger.log("log","ClickTracker: Tracking click",r),this.trackingCallback(r))}}}},e.prototype.findTrackableElement=function(e){var t=this.config.selectors||g;try{var n=e.closest('[data-lucia-track]:not([data-lucia-track="false"])');if(n&&n!==document.body&&document.body.contains(n))return this.config.selectors&&this.config.selectors!==g?t.some(function(e){try{return n.matches(e)}catch(e){return!1}})?n:null:n;var r=t.join(", "),i=e.closest(r);return i&&i!==document.body&&document.body.contains(i)?i:null}catch(t){this.logger.log("warn","ClickTracker: Invalid combined selector, using fallback",t);for(var o=e;o&&o!==document.body;){if(this.isTrackable(o))return o;o=o.parentElement}return null}},e.prototype.isTrackable=function(e){var t=this;return(this.config.selectors||g).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid selector "'.concat(n,'"'),e),!1}})},e.prototype.shouldIgnore=function(e){var t=this;return(this.config.ignore||w).some(function(n){try{return e.matches(n)}catch(e){return t.logger.log("warn",'ClickTracker: Invalid ignore selector "'.concat(n,'"'),e),!1}})},e.prototype.isDebounced=function(e){var t=Date.now(),n=this.debounceTimers.get(e);return!!(n&&t-n<500)||(this.debounceTimers.set(e,t),this.debounceTimers.size>100&&this.cleanupDebounceTimers(),!1)},e.prototype.cleanupDebounceTimers=function(){var e=this,t=Date.now();Array.from(this.debounceTimers.entries()).forEach(function(n){var r=n[0],i=n[1];t-i>1e3&&e.debounceTimers.delete(r)})},e.prototype.extractTrackingData=function(e){var t,n=this.getElementIdentifier(e);if(!n)return this.logger.log("warn","ClickTracker: Could not generate identifier for element",e),null;var r={button:n,elementType:this.getElementType(e),timestamp:Date.now()},i=null===(t=e.textContent)||void 0===t?void 0:t.trim();i&&(this.privacyGuard.containsSensitiveData(i)||(r.text=this.sanitizeText(i))),"a"===e.tagName.toLowerCase()?r.href=e.getAttribute("href"):r.href=null;var o=this.extractMetadata(e);return o&&Object.keys(o).length>0&&(r.meta=o),r},e.prototype.getElementIdentifier=function(e){var t,n=e.getAttribute("data-lucia-track");if(n&&"false"!==n)return n;var r=e.getAttribute("id");if(r)return r;var i=e.getAttribute("name");if(i)return i;var o=e.getAttribute("aria-label");if(o)return o;if("a"===e.tagName.toLowerCase()){var a=e.getAttribute("href");if(a)return"link:".concat(a)}var s=null===(t=e.textContent)||void 0===t?void 0:t.trim();if(s)return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using text content as identifier for element. Consider adding data-lucia-track attribute.",e),"text:".concat(this.sanitizeText(s).substring(0,50));var u=this.generateCSSPath(e);return this.sdkConfig.debug&&this.logger.log("warn","ClickTracker: Using CSS path as identifier. Consider adding data-lucia-track attribute.",e),"path:".concat(u)},e.prototype.getElementType=function(e){var t=e.tagName.toLowerCase();if("a"===t)return"link";if("button"===t)return"button";var n=e.getAttribute("role");return n||t},e.prototype.sanitizeText=function(e){return e.trim().replace(/\s+/g," ").substring(0,100)},e.prototype.generateCSSPath=function(e){for(var t=[],n=e;n&&n!==document.body&&t.length<5;){var r=n.tagName.toLowerCase();if(n.id){r+="#".concat(n.id),t.unshift(r);break}var i=n.getAttribute("class");if(i){var o=i.trim().split(/\s+/).slice(0,2);o.length>0&&(r+=".".concat(o.join(".")))}t.unshift(r),n=n.parentElement}return t.join(" > ")},e.prototype.extractMetadata=function(e){var t={},n=e.attributes;return Array.from(n).forEach(function(e){if(e.name.startsWith("data-lucia-meta-")){var n=e.name.replace("data-lucia-meta-","").replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});t[n]=e.value}}),Object.keys(t).length>0?t:null},e.prototype.enable=function(){this.config.enabled||(this.config.enabled=!0,this.attachListener(),this.logger.log("log","ClickTracker: Enabled"))},e.prototype.disable=function(){this.config.enabled=!1,this.logger.log("log","ClickTracker: Disabled")},e.prototype.destroy=function(){this.listenerAttached&&this.boundHandleClick&&"undefined"!=typeof document&&(document.removeEventListener("click",this.boundHandleClick),this.listenerAttached=!1),this.debounceTimers.clear(),this.boundHandleClick=null,this.logger.log("log","ClickTracker: Destroyed")},e}(),m=new a(l.store);function y(){return r(this,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),(null==(e=window.ethereum)?void 0:e.request)?[4,e.request({method:"eth_accounts"})]:[2,null];case 1:return(t=r.sent())&&t.length>0?[2,t[0]]:[2,null];case 2:return n=r.sent(),m.log("error","Error checking connected wallet:",n),[2,null];case 3:return[2]}})})}function b(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),window.ethereum?window.ethereum.isMetaMask?[2,"MetaMask"]:window.ethereum.request?[4,window.ethereum.request({method:"wallet_getName"})]:[2,null]:[2,null];case 1:return[2,t.sent()||null];case 2:return e=t.sent(),m.log("error","Error getting wallet name:",e),[2,null];case 3:return[2]}})})}function k(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){return window.ethereum?(e={isMetaMask:!!window.ethereum.isMetaMask,isCoinbaseWallet:!!window.ethereum.isCoinbaseWallet||!!window.ethereum.isCoinbase,isWalletConnect:!!window.ethereum.isWalletConnect,isTrust:!!window.ethereum.isTrust||!!window.ethereum.isTrustWallet,isImToken:!!window.ethereum.isImToken,isBraveWallet:!!window.ethereum.isBraveWallet,isTokenPocket:!!window.ethereum.isTokenPocket,isStatus:!!window.ethereum.isStatus,isTally:!(!window.ethereum.isTally&&!window.ethereum.isTallyWallet),isAlphaWallet:!!window.ethereum.isAlphaWallet,isOpera:!!window.ethereum.isOpera,isCoin98:!!window.ethereum.isCoin98,isMathWallet:!!window.ethereum.isMathWallet,isOneInch:!(!window.ethereum.isOneInchIOSWallet&&!window.ethereum.isOneInchAndroidWallet),isRainbow:!!window.ethereum.isRainbow,isBinanceChainWallet:!1,isFrame:!!window.ethereum.isFrame,userAgent:window.navigator.userAgent,chainId:window.ethereum.chainId||void 0,networkVersion:window.ethereum.networkVersion||void 0,name:""},Object.values(e).some(Boolean)||(Object.prototype.hasOwnProperty.call(window.ethereum,"_metamask")&&(e.isMetaMask=!0),window.BinanceChain&&(e.isBinanceChainWallet=!0),window.ethereum.isFrame&&(e.isFrame=!0),"function"==typeof window.ethereum.request&&void 0===window.ethereum._metamask&&(e.isPossiblyGenericInjectedProvider=!0)),e.name=function(e){if(e.isMetaMask)return"MetaMask";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isWalletConnect)return"WalletConnect";if(e.isTrust)return"Trust Wallet";if(e.isImToken)return"imToken";if(e.isBraveWallet)return"Brave Wallet";if(e.isTokenPocket)return"TokenPocket";if(e.isStatus)return"Status";if(e.isTally)return"Tally";if(e.isAlphaWallet)return"AlphaWallet";if(e.isOpera)return"Opera";if(e.isCoin98)return"Coin98";if(e.isMathWallet)return"MathWallet";if(e.isOneInch)return"1inch Wallet";if(e.isRainbow)return"Rainbow";if(e.isBinanceChainWallet)return"Binance Chain Wallet";if(e.isFrame)return"Frame";var t=e.userAgent.toLowerCase();return t.includes("trust")?"Trust Wallet (UA)":t.includes("rainbow")?"Rainbow (UA)":"Unknown Provider"}(e),[2,e]):[2,null]})})}var C=new a(l.store);function T(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),window.solana?window.solana.isConnected&&window.solana.publicKey?[2,window.solana.publicKey.toString()]:[3,6]:[3,1];case 1:return window.solflare?window.solflare.isConnected&&window.solflare.publicKey?[2,window.solflare.publicKey.toString()]:[3,6]:[3,2];case 2:if(!(null===(o=window.phantom)||void 0===o?void 0:o.solana))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,window.phantom.solana.connect({onlyIfTrusted:!0})];case 4:return i.sent()&&window.phantom.solana.publicKey?[2,window.phantom.solana.publicKey.toString()]:[3,6];case 5:return e=i.sent(),C.log("error","Error silently connecting to Phantom wallet:",e),[3,6];case 6:return t=[],(null===(a=window.walletAdapterNetwork)||void 0===a?void 0:a.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(s=window.SolanaWalletAdapterContext)||void 0===s?void 0:s.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(e){return e.connected&&e.publicKey}))?[2,n.publicKey.toString()]:[2,null];case 7:return r=i.sent(),C.log("error","Error detecting Solana wallet:",r),[2,null];case 8:return[2]}})})}function A(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,T()];case 1:return(e=i.sent())?(null===(r=window.phantom)||void 0===r?void 0:r.solana)?[2,"Phantom"]:window.solflare?[2,"Solflare"]:(t=[],(null===(o=window.walletAdapterNetwork)||void 0===o?void 0:o.adapters)&&t.push.apply(t,window.walletAdapterNetwork.adapters),(null===(a=window.SolanaWalletAdapterContext)||void 0===a?void 0:a.current)&&t.push(window.SolanaWalletAdapterContext.current),(n=t.find(function(t){return t.connected&&t.publicKey&&t.publicKey.toString()===e}))?[2,n.name||"Unknown Wallet"]:[2,null]):[2,null]}})})}function S(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return W?[2,W]:(e={cores:x(function(){return navigator.hardwareConcurrency}),memory:x(function(){return navigator.deviceMemory}),cpuClass:x(function(){return navigator.cpuClass}),touch:j(),devicePixelRatio:x(function(){return window.devicePixelRatio})},t={width:x(function(){return window.screen.width}),height:x(function(){return window.screen.height}),colorDepth:x(function(){return window.screen.colorDepth}),availHeight:x(function(){return window.screen.availHeight}),availWidth:x(function(){return window.screen.availWidth}),orientation:{type:x(function(){return window.screen.orientation.type}),angle:x(function(){return window.screen.orientation.angle})}},s={language:x(function(){return navigator.language}),encoding:x(function(){return TextDecoder.encoding}),timezone:x(function(){return-(new Date).getTimezoneOffset()/60}),pluginsLength:x(function(){return navigator.plugins.length}),pluginNames:x(function(){return Array.from(navigator.plugins,function(e){return e.name})}),applePayAvailable:_()},[4,O()]);case 1:return s.uniqueHash=i.sent(),s.colorGamut=U(),s.contrastPreference=M(),n=s,r={navPer:x(function(){return navigator.permissions.webglVersion}),renderedPer:x(function(){return navigator.permissions.RENDERER}),geoPer:x(function(){return navigator.permissions.geolocation})},o={localStorage:x(function(){return!!window.localStorage}),indexedDB:x(function(){return!!window.indexedDB}),openDB:x(function(){return window.openDatabase})},W=a={device:e,screen:t,browser:n,permissions:r,storage:o},[2,a]}})})}function I(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:return[4,Promise.all([T(),y(),b(),A(),k()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],[2,{walletAddress:n,solanaAddress:t,providerInfo:a&&E(a),walletName:r,solWalletName:o}]}})})}function P(){var e=new URL(window.location.href).searchParams,t={};return e.forEach(function(e,n){(n.startsWith("utm_")||n.includes("id")||"ref"===n||"source"===n)&&(t[n]=e)}),t}function x(e,t){try{return e()}catch(e){return t}}function E(e){var t={};return Object.keys(e).forEach(function(n){var r=n;e[r]&&(t[r]=e[r])}),t}function D(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=new TextEncoder,n=t.encode(e),[4,crypto.subtle.digest("SHA-256",n)];case 1:return r=i.sent(),[2,Array.from(new Uint8Array(r)).map(function(e){return e.toString(16).padStart(2,"0")}).join("")]}})})}var W=null;function O(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){try{return e=document.createElement("canvas"),(t=e.getContext("2d",{willReadFrequently:!0}))?(n=200,r=120,e.width=n,e.height=r,e.style.width="".concat(n,"px"),e.style.height="".concat(r,"px"),t.fillStyle="#ffffff",t.fillRect(0,0,n,r),t.fillStyle="#ff00ff",t.fillRect(10,10,100,100),t.fillStyle="#00ffff",t.beginPath(),t.arc(150,50,40,0,2*Math.PI,!0),t.fill(),o=t.getImageData(0,0,n,r).data,a=[[20,20],[60,60],[100,100],[150,50],[150,60],[140,50],[5,5]].map(function(e){var t=e[0],r=4*(e[1]*n+t);return"".concat(o[r],",").concat(o[r+1],",").concat(o[r+2],",").concat(o[r+3],";")}).join(""),[2,D(a)]):[2,void 0]}catch(e){return[2,void 0]}return[2]})})}function j(){try{return!!document.createEvent("TouchEvent")}catch(e){return!1}}function _(){var e;try{return"function"==typeof(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments)&&window.ApplePaySession.canMakePayments()}catch(e){return}}function M(){try{var e=window.matchMedia,t=function(t){return e("(prefers-contrast: ".concat(t,")")).matches};return t("no-preference")?"None":t("high")||t("more")?"More":t("low")||t("less")?"Less":t("forced")?"ForcedColors":void 0}catch(e){return}}function U(){try{return["rec2020","p3","srgb","display-p3","adobe-rgb"].filter(function(e){return window.matchMedia("(color-gamut: ".concat(e,")")).matches})}catch(e){return[]}}const L=[];for(let e=0;e<256;++e)L.push((e+256).toString(16).slice(1));let R;const K=new Uint8Array(16);var N={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function B(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!R){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R(K)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(L[e[t+0]]+L[e[t+1]]+L[e[t+2]]+L[e[t+3]]+"-"+L[e[t+4]]+L[e[t+5]]+"-"+L[e[t+6]]+L[e[t+7]]+"-"+L[e[t+8]]+L[e[t+9]]+"-"+L[e[t+10]]+L[e[t+11]]+L[e[t+12]]+L[e[t+13]]+L[e[t+14]]+L[e[t+15]]).toLowerCase()}(r)}var q="luci_session",V=new a(l.store);function z(){try{var e=sessionStorage.getItem(q);return e?JSON.parse(e):null}catch(e){return V.log("error","Error retrieving session data:",e),null}}function Q(){var e,t={id:N.randomUUID&&!e?N.randomUUID():B(e),timestamp:Date.now()};return sessionStorage.setItem(q,JSON.stringify(t)),t}function F(){var e=localStorage.getItem("lid");return"undefined"===e||"null"===e?(localStorage.removeItem("lid"),null):e}function H(){var e=localStorage.getItem("luc_uid");return"undefined"===e||"null"===e?(localStorage.removeItem("luc_uid"),null):e}var G=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.clickTracker=null,t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,e),o.prototype.authenticate=function(){this.httpClient.post("/api/key/auth",{})},o.prototype.init=function(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a,s;return i(this,function(i){switch(i.label){case 0:return(e=z())||(e=Q()),[4,S()];case 1:return t=i.sent(),n=new URL(window.location.href),r=n.searchParams.get("lucia"),[4,I()];case 2:return o=i.sent(),a={id:e.id},e.hash&&(a.hash=e.hash),[4,this.httpClient.post("/api/sdk/init",{user:{name:H()},data:t,walletData:o,session:a,redirectHash:r,utm:P()},!1)];case 3:return(s=i.sent())&&(s.lid&&localStorage.setItem("lid",s.lid),s.session&&(u=s.session,c={id:u.id,hash:u.hash,timestamp:Date.now()},sessionStorage.setItem(q,JSON.stringify(c)))),this.initAutoTracking(),[2]}var u,c})})},o.prototype.initAutoTracking=function(){var e;this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null);var t,n=null===(e=this.store.config)||void 0===e?void 0:e.autoTrackClicks;n&&(!1!==(t="boolean"==typeof n?{enabled:n}:n).enabled&&(this.clickTracker=new v(this.store.config,t,this.handleAutoTrackedClick.bind(this),this.logger),this.logger.log("log","Auto-tracking initialized",t)))},o.prototype.handleAutoTrackedClick=function(e){var t={elementType:e.elementType,text:e.text,href:e.href,meta:e.meta};this.buttonClick(e.button,t)},o.prototype.userInfo=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),e&&localStorage.setItem("luc_uid",e),o={user:{name:e,userInfo:t},session:r},n&&(o.lid=n),[4,this.httpClient.post("/api/sdk/user",o)];case 1:return i.sent(),[2]}})})},o.prototype.pageView=function(e){return r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=F(),n=z(),r={page:e,user:{name:H()},session:n},t&&(r.lid=t),[4,this.httpClient.post("/api/sdk/page",r)];case 1:return i.sent(),[2]}})})},o.prototype.trackConversion=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={tag:e,amount:t,event:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/conversion",a)];case 1:return i.sent(),[2]}})})},o.prototype.buttonClick=function(e,t){return r(this,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=F(),r=z(),o={button:e,user:{name:H()},session:r},n&&(o.lid=n),t&&(t.elementType&&(o.elementType=t.elementType),t.text&&(o.text=t.text),void 0!==t.href&&(o.href=t.href),t.meta&&(o.meta=t.meta),o.timestamp=Date.now()),[4,this.httpClient.post("/api/sdk/click",o)];case 1:return i.sent(),[2]}})})},o.prototype.sendWalletInfo=function(e,t,n){return r(this,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return r=F(),o=z(),a={walletAddress:e,chainId:t,walletName:n,user:{name:H()},session:o},r&&(a.lid=r),[4,this.httpClient.post("/api/sdk/wallet",a)];case 1:return i.sent(),[2]}})})},o.prototype.trackUserAcquisition=function(e){return r(this,arguments,void 0,function(e,t){var r,o,a;return void 0===t&&(t={}),i(this,function(i){switch(i.label){case 0:return[4,S()];case 1:return r=i.sent(),o=P(),a=z(),[4,this.httpClient.post("/api/sdk/acquisition",{user:{name:e},session:a,data:n({timestamp:(new Date).toISOString(),browserData:r,utmParams:o},t)})];case 2:return i.sent(),[2]}})})},o.prototype.checkMetaMaskConnection=function(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},o.prototype.destroy=function(){this.clickTracker&&(this.clickTracker.destroy(),this.clickTracker=null)},o}(d),Z=null,J=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;if(!e)throw new Error("LuciaSDK not initialized. Please call LuciaSDK.init() first");return e},X={init:function(e){if("undefined"==typeof window)return Promise.reject(new Error("LuciaSDK requires a browser environment"));if(Z)return Z;if(window.__luciaInitPromise)return Z=window.__luciaInitPromise;if(!(null==e?void 0:e.apiKey))return Promise.reject(new Error("apiKey is required in config"));var t=r(void 0,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,(t=new G(e)).init()];case 1:return n.sent(),[2,t]}})});return Z=t,window.__luciaInitPromise=t,t},userInfo:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().userInfo(e,t)]}})})},pageView:function(e){return r(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,J()];case 1:return[2,t.sent().pageView(e)]}})})},trackConversion:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().trackConversion(e,t,n)]}})})},buttonClick:function(e,t){return r(void 0,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().buttonClick(e,t)]}})})},sendWalletInfo:function(e,t,n){return r(void 0,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:return[2,r.sent().sendWalletInfo(e,t,n)]}})})},trackUserAcquisition:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return r(void 0,o([e],t,!0),void 0,function(e,t){return void 0===t&&(t={}),i(this,function(n){switch(n.label){case 0:return[4,J()];case 1:return[2,n.sent().trackUserAcquisition(e,t)]}})})},checkMetaMaskConnection:function(){var e,t,n;return!(!(null===(t=null===(e=window.ethereum)||void 0===e?void 0:e.isConnected)||void 0===t?void 0:t.call(e))||!(null===(n=window.ethereum)||void 0===n?void 0:n.selectedAddress))},VERSION:s};if("undefined"!=typeof window){window.LuciaSDK=X;var Y=function(){var e=document.currentScript||document.querySelector("script[data-api-key]"),t=null==e?void 0:e.getAttribute("data-api-key");if(t){var r=e.getAttribute("data-debug-url"),i=e.getAttribute("data-auto-track-clicks"),o=e.getAttribute("data-track-selectors");X.init(n(n(n({apiKey:t},r&&{debugURL:r}),"true"===i&&{autoTrackClicks:!o||{enabled:!0,selectors:o.split(",").map(function(e){return e.trim()})}}),"false"===i&&{autoTrackClicks:!1})).catch(function(e){return console.error("LuciaSDK auto-init failed:",e)})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()}e.__resetInstance=function(){var e=Z||"undefined"!=typeof window&&window.__luciaInitPromise;e&&e.then(function(e){return e.destroy()}).catch(function(){}),Z=null,"undefined"!=typeof window&&delete window.__luciaInitPromise},e.default=X,e.filterObject=E,e.getApplePayAvailable=_,e.getBrowserData=S,e.getCanvasFingerprint=O,e.getColorGamut=U,e.getContrastPreference=M,e.getUtmParams=P,e.getWalletData=I,e.isTouchEnabled=j,e.safeAccess=x,Object.defineProperty(e,"__esModule",{value:!0})});
File without changes
File without changes
File without changes
File without changes
File without changes