import { WebStorageAdapter } from '../chunk-OLHGZXN3.mjs';
import '../chunk-BJTO5JO5.mjs';
import React5, { useEffect, useCallback, useRef, useState } from 'react';

// src/analytics/types.ts
var EventType = /* @__PURE__ */ ((EventType2) => {
  EventType2["PAGE_VIEW"] = "page_view";
  EventType2["PAGE_LEAVE"] = "page_leave";
  EventType2["CLICK"] = "click";
  EventType2["SCROLL"] = "scroll";
  EventType2["INPUT"] = "input";
  EventType2["SUBMIT"] = "submit";
  EventType2["LOGIN"] = "login";
  EventType2["LOGOUT"] = "logout";
  EventType2["REGISTER"] = "register";
  EventType2["SEARCH"] = "search";
  EventType2["SHARE"] = "share";
  EventType2["PERFORMANCE"] = "performance";
  EventType2["ERROR"] = "error";
  EventType2["API_CALL"] = "api_call";
  EventType2["CUSTOM"] = "custom";
  return EventType2;
})(EventType || {});
var EventPriority = /* @__PURE__ */ ((EventPriority2) => {
  EventPriority2[EventPriority2["LOW"] = 0] = "LOW";
  EventPriority2[EventPriority2["NORMAL"] = 1] = "NORMAL";
  EventPriority2[EventPriority2["HIGH"] = 2] = "HIGH";
  EventPriority2[EventPriority2["CRITICAL"] = 3] = "CRITICAL";
  return EventPriority2;
})(EventPriority || {});

// src/analytics/core/EventQueue.ts
var EventQueue = class {
  constructor(maxSize = 100) {
    this.queue = [];
    this.maxSize = maxSize;
  }
  /**
   * 添加事件到队列
   */
  enqueue(event) {
    if (this.queue.length >= this.maxSize) {
      this.removeLowestPriorityEvent();
    }
    this.queue.push(event);
    this.queue.sort((a, b) => b.priority - a.priority);
  }
  /**
   * 批量添加事件
   */
  enqueueBatch(events) {
    events.forEach((event) => this.enqueue(event));
  }
  /**
   * 获取指定数量的事件
   */
  dequeue(count) {
    return this.queue.splice(0, count);
  }
  /**
   * 获取所有事件
   */
  dequeueAll() {
    const events = [...this.queue];
    this.queue = [];
    return events;
  }
  /**
   * 获取高优先级事件
   */
  getHighPriorityEvents() {
    const highPriorityEvents = this.queue.filter(
      (event) => event.priority >= 2
      // HIGH 和 CRITICAL
    );
    this.queue = this.queue.filter((event) => event.priority < 2);
    return highPriorityEvents;
  }
  /**
   * 查看队列长度
   */
  size() {
    return this.queue.length;
  }
  /**
   * 队列是否为空
   */
  isEmpty() {
    return this.queue.length === 0;
  }
  /**
   * 队列是否已满
   */
  isFull() {
    return this.queue.length >= this.maxSize;
  }
  /**
   * 清空队列
   */
  clear() {
    this.queue = [];
  }
  /**
   * 移除最低优先级的事件
   */
  removeLowestPriorityEvent() {
    if (this.queue.length === 0) return;
    let lowestPriorityIndex = 0;
    let lowestPriority = this.queue[0]?.priority ?? 0;
    for (let i = 1; i < this.queue.length; i++) {
      const currentPriority = this.queue[i]?.priority ?? 0;
      if (currentPriority < lowestPriority) {
        lowestPriority = currentPriority;
        lowestPriorityIndex = i;
      }
    }
    this.queue.splice(lowestPriorityIndex, 1);
  }
  /**
   * 获取队列快照（不移除事件）
   */
  snapshot() {
    return [...this.queue];
  }
};

// src/analytics/core/Uploader.ts
var Uploader = class {
  constructor(config) {
    this.uploading = false;
    this.retryQueue = /* @__PURE__ */ new Map();
    this.config = config;
  }
  /**
   * 上传事件
   */
  async upload(events) {
    if (events.length === 0) return true;
    const isOnline = await this.config.networkAdapter.isOnline();
    if (!isOnline) {
      await this.saveToLocal(events);
      return false;
    }
    try {
      this.uploading = true;
      const response = await this.config.networkAdapter.upload(this.config.endpoint, events);
      if (response.success) {
        this.config.onSuccess?.(events);
        return true;
      } else {
        throw new Error(response.message || "Upload failed");
      }
    } catch (error) {
      const err = error instanceof Error ? error : new Error(String(error));
      this.config.onError?.(err, events);
      await this.addToRetryQueue(events);
      return false;
    } finally {
      this.uploading = false;
    }
  }
  /**
   * 批量上传
   */
  async uploadBatch(events) {
    const batches = this.splitIntoBatches(events, this.config.batchSize);
    const results = await Promise.all(batches.map((batch) => this.upload(batch)));
    return results.every((result) => result);
  }
  /**
   * 重试失败的上传
   */
  async retryFailedUploads() {
    if (this.uploading || this.retryQueue.size === 0) return;
    const isOnline = await this.config.networkAdapter.isOnline();
    if (!isOnline) return;
    const entries = Array.from(this.retryQueue.entries());
    for (const [key, item] of entries) {
      if (item.retryCount >= this.config.retryTimes) {
        await this.saveToLocal(item.events);
        this.retryQueue.delete(key);
        continue;
      }
      await this.delay(this.config.retryInterval * (item.retryCount + 1));
      const success = await this.upload(item.events);
      if (success) {
        this.retryQueue.delete(key);
      } else {
        item.retryCount++;
      }
    }
  }
  /**
   * 上传本地缓存的事件
   */
  async uploadCachedEvents() {
    try {
      const cachedEvents = await this.config.storageAdapter.getEvents();
      if (cachedEvents.length > 0) {
        const success = await this.uploadBatch(cachedEvents);
        if (success) {
          await this.config.storageAdapter.clearEvents();
        }
      }
    } catch (error) {
      console.error("Failed to upload cached events:", error);
    }
  }
  /**
   * 保存事件到本地存储
   */
  async saveToLocal(events) {
    try {
      const existingEvents = await this.config.storageAdapter.getEvents();
      const allEvents = [...existingEvents, ...events];
      await this.config.storageAdapter.saveEvents(allEvents);
    } catch (error) {
      console.error("Failed to save events to local storage:", error);
    }
  }
  /**
   * 添加到重试队列
   */
  async addToRetryQueue(events) {
    const key = `${Date.now()}_${Math.random()}`;
    this.retryQueue.set(key, {
      events,
      retryCount: 0
    });
  }
  /**
   * 分割成批次
   */
  splitIntoBatches(events, batchSize) {
    const batches = [];
    for (let i = 0; i < events.length; i += batchSize) {
      batches.push(events.slice(i, i + batchSize));
    }
    return batches;
  }
  /**
   * 延迟函数
   */
  delay(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
  }
  /**
   * 是否正在上传
   */
  isUploading() {
    return this.uploading;
  }
  /**
   * 获取重试队列大小
   */
  getRetryQueueSize() {
    return this.retryQueue.size;
  }
  /**
   * 清空重试队列
   */
  clearRetryQueue() {
    this.retryQueue.clear();
  }
};

// src/analytics/core/Analytics.ts
var SDK_VERSION = "1.0.0";
var Analytics = class {
  constructor(config, storageAdapter, networkAdapter, deviceAdapter) {
    this.sessionId = "";
    this.deviceId = "";
    this.deviceInfo = null;
    this.initialized = false;
    this.batchTimer = null;
    if (config.adapter) {
      this.storageAdapter = config.adapter.storage;
      this.networkAdapter = config.adapter.network;
      this.deviceAdapter = config.adapter.device;
    } else if (storageAdapter && networkAdapter && deviceAdapter) {
      this.storageAdapter = storageAdapter;
      this.networkAdapter = networkAdapter;
      this.deviceAdapter = deviceAdapter;
    } else {
      throw new Error("Analytics initialization failed: adapter is required");
    }
    const serverUrl = config.serverUrl || config.endpoint || "/api/analytics/events";
    const platform = config.platform || "web";
    this.config = {
      ...config,
      appId: config.appId,
      appVersion: config.appVersion || "1.0.0",
      platform,
      endpoint: serverUrl,
      batchSize: config.batchSize ?? 10,
      batchInterval: config.batchInterval ?? 5e3,
      maxQueueSize: config.maxQueueSize ?? 100,
      retryTimes: config.retryTimes ?? 3,
      retryInterval: config.retryInterval ?? 1e3,
      enableAutoPageView: config.enableAutoPageView ?? true,
      enableAutoClick: config.enableAutoClick ?? false,
      enableAutoError: config.enableAutoError ?? true,
      enableAutoPerformance: config.enableAutoPerformance ?? true,
      debug: config.debug ?? false,
      ignoreUrls: config.ignoreUrls ?? [],
      ignoreErrors: config.ignoreErrors ?? [],
      beforeSend: config.beforeSend
    };
    this.eventQueue = new EventQueue(this.config.maxQueueSize);
    this.uploader = new Uploader({
      endpoint: this.config.endpoint,
      batchSize: this.config.batchSize,
      retryTimes: this.config.retryTimes,
      retryInterval: this.config.retryInterval,
      networkAdapter: this.networkAdapter,
      storageAdapter: this.storageAdapter,
      onSuccess: (events) => this.onUploadSuccess(events),
      onError: (error, events) => this.onUploadError(error, events)
    });
    this.init().catch((error) => {
      console.error("Failed to initialize Analytics:", error);
    });
  }
  /**
   * 初始化
   */
  async init() {
    if (this.initialized) {
      this.log("Analytics already initialized");
      return;
    }
    try {
      await this.initDeviceInfo();
      await this.initSession();
      await this.uploader.uploadCachedEvents();
      this.startBatchTimer();
      if (typeof window !== "undefined") {
        window.addEventListener("analytics-debug-changed", ((e) => {
          this.log(`Debug mode changed: ${e.detail.enabled ? "enabled" : "disabled"}`);
        }));
      }
      this.initialized = true;
      this.log("Analytics initialized successfully");
    } catch (error) {
      console.error("Failed to initialize analytics:", error);
      throw error;
    }
  }
  /**
   * 追踪事件（简化版本，支持两种调用方式）
   */
  track(eventNameOrType, propertiesOrName, maybeProperties, priority = 1 /* NORMAL */) {
    if (!this.initialized) {
      console.warn("Analytics not initialized yet, queuing event...");
      setTimeout(
        () => this.track(eventNameOrType, propertiesOrName, maybeProperties, priority),
        100
      );
      return;
    }
    let eventType;
    let eventName;
    let properties;
    if (typeof propertiesOrName === "string") {
      eventType = eventNameOrType;
      eventName = propertiesOrName;
      properties = maybeProperties;
    } else {
      eventType = "custom" /* CUSTOM */;
      eventName = eventNameOrType;
      properties = propertiesOrName;
    }
    const event = this.createEvent(eventType, eventName, properties, priority);
    const processedEvent = this.config.beforeSend?.(event) ?? event;
    if (!processedEvent) {
      this.log("Event filtered by beforeSend hook", event);
      return;
    }
    this.eventQueue.enqueue(processedEvent);
    this.log("Event tracked", processedEvent);
    if (priority >= 2 /* HIGH */) {
      this.flushHighPriority();
    }
    if (this.eventQueue.isFull()) {
      this.flush();
    }
  }
  /**
   * 追踪页面浏览
   */
  trackPageView(pageUrl, pageTitle, properties) {
    this.track(
      "page_view" /* PAGE_VIEW */,
      "page_view",
      {
        page_url: pageUrl,
        page_title: pageTitle,
        ...properties
      },
      1 /* NORMAL */
    );
  }
  /**
   * 追踪点击事件
   */
  trackClick(elementInfo, properties) {
    this.track(
      "click" /* CLICK */,
      "click",
      {
        ...elementInfo,
        ...properties
      },
      0 /* LOW */
    );
  }
  /**
   * 追踪错误
   */
  trackError(errorMessage, errorStack, errorType, properties) {
    this.track(
      "error" /* ERROR */,
      "error",
      {
        error_message: errorMessage,
        error_stack: errorStack,
        error_type: errorType,
        ...properties
      },
      2 /* HIGH */
    );
  }
  /**
   * 追踪性能指标
   */
  trackPerformance(metricName, metricValue, metricUnit, properties) {
    this.track(
      "performance" /* PERFORMANCE */,
      "performance",
      {
        metric_name: metricName,
        metric_value: metricValue,
        metric_unit: metricUnit,
        ...properties
      },
      0 /* LOW */
    );
  }
  /**
   * 追踪 API 调用
   */
  trackApiCall(apiUrl, apiMethod, apiStatus, duration, success, properties) {
    this.track(
      "api_call" /* API_CALL */,
      "api_call",
      {
        api_url: apiUrl,
        api_method: apiMethod,
        api_status: apiStatus,
        duration,
        success,
        ...properties
      },
      1 /* NORMAL */
    );
  }
  /**
   * 设置用户ID
   */
  setUserId(userId) {
    this.config.userId = userId;
    this.log("User ID set", userId);
  }
  /**
   * 设置用户信息（包括用户ID和其他属性）
   */
  setUser(userInfo) {
    const { userId, ...otherProps } = userInfo;
    this.config.userId = userId;
    this.config.customProperties = {
      ...this.config.customProperties,
      ...otherProps
    };
    this.log("User info set", userInfo);
  }
  /**
   * 设置自定义属性
   */
  setCustomProperties(properties) {
    this.config.customProperties = {
      ...this.config.customProperties,
      ...properties
    };
    this.log("Custom properties set", properties);
  }
  /**
   * 立即上传所有事件
   */
  async flush() {
    if (this.eventQueue.isEmpty()) {
      return;
    }
    const events = this.eventQueue.dequeueAll();
    await this.uploader.upload(events);
  }
  /**
   * 立即上传高优先级事件
   */
  async flushHighPriority() {
    const highPriorityEvents = this.eventQueue.getHighPriorityEvents();
    if (highPriorityEvents.length > 0) {
      await this.uploader.upload(highPriorityEvents);
    }
  }
  /**
   * 销毁实例
   */
  async destroy() {
    if (this.batchTimer) {
      clearInterval(this.batchTimer);
      this.batchTimer = null;
    }
    await this.flush();
    this.initialized = false;
    this.log("Analytics destroyed");
  }
  /**
   * 创建事件对象
   */
  createEvent(eventType, eventName, properties, priority = 1 /* NORMAL */) {
    let pageUrl;
    let pageTitle;
    let referrer;
    if (typeof window !== "undefined") {
      pageUrl = window.location.href;
      pageTitle = document.title;
      referrer = document.referrer || void 0;
    }
    return {
      event_id: this.generateEventId(),
      event_type: eventType,
      event_name: eventName,
      timestamp: Date.now(),
      priority,
      user_id: this.config.userId,
      session_id: this.sessionId,
      device_id: this.deviceId,
      page_url: pageUrl,
      page_title: pageTitle,
      referrer,
      properties: {
        ...this.config.customProperties,
        ...properties
      },
      platform: this.getPlatform(),
      app_version: this.config.appVersion,
      sdk_version: SDK_VERSION
    };
  }
  /**
   * 初始化设备信息
   */
  async initDeviceInfo() {
    try {
      let cachedDeviceInfo = await this.storageAdapter.getDeviceInfo();
      if (!cachedDeviceInfo) {
        this.deviceInfo = await this.deviceAdapter.getDeviceInfo();
        this.deviceId = await this.deviceAdapter.generateDeviceId();
        await this.storageAdapter.saveDeviceInfo(this.deviceInfo);
      } else {
        this.deviceInfo = cachedDeviceInfo;
        this.deviceId = cachedDeviceInfo.device_id;
      }
    } catch (error) {
      console.error("Failed to init device info:", error);
      this.deviceId = `temp_${Date.now()}_${Math.random()}`;
    }
  }
  /**
   * 初始化会话
   */
  async initSession() {
    try {
      const cachedSessionId = await this.storageAdapter.getSessionId();
      if (cachedSessionId) {
        this.sessionId = cachedSessionId;
      } else {
        this.sessionId = this.generateSessionId();
        await this.storageAdapter.saveSessionId(this.sessionId);
      }
    } catch (error) {
      console.error("Failed to init session:", error);
      this.sessionId = this.generateSessionId();
    }
  }
  /**
   * 启动批量上传定时器
   */
  startBatchTimer() {
    this.batchTimer = setInterval(() => {
      if (!this.eventQueue.isEmpty()) {
        this.flush();
      }
      this.uploader.retryFailedUploads();
    }, this.config.batchInterval);
  }
  /**
   * 上传成功回调
   */
  onUploadSuccess(events) {
    this.log("Events uploaded successfully", events);
  }
  /**
   * 上传失败回调
   */
  onUploadError(error, events) {
    this.log("Failed to upload events", { error, events });
  }
  /**
   * 生成事件ID
   */
  generateEventId() {
    return `${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
  }
  /**
   * 生成会话ID
   */
  generateSessionId() {
    return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
  }
  /**
   * 获取平台标识
   */
  getPlatform() {
    return this.config.platform || "unknown";
  }
  /**
   * 日志输出
   */
  log(message, data) {
    const dynamicDebug = typeof window !== "undefined" ? localStorage.getItem("analytics-debug") === "true" : false;
    if (this.config.debug || dynamicDebug) {
      console.log(`[Analytics] ${message}`, data ?? "");
    }
  }
  /**
   * 获取队列状态
   */
  getQueueStatus() {
    return {
      size: this.eventQueue.size(),
      isFull: this.eventQueue.isFull(),
      isEmpty: this.eventQueue.isEmpty()
    };
  }
  /**
   * 获取初始化状态
   */
  isInitialized() {
    return this.initialized;
  }
};

// src/analytics/client/presets.ts
function createWebConfig(appId, options = {}) {
  return {
    appId,
    appVersion: options.appVersion || "1.0.0",
    endpoint: options.endpoint || "/api/analytics/events",
    platform: "web",
    enableAutoPageView: options.enableAutoPageView ?? true,
    debug: options.debug ?? (typeof process !== "undefined" && process.env?.NODE_ENV === "development")
    // adapter 需要由调用者提供
  };
}
function createMobileConfig(appId, options = {}) {
  return {
    appId,
    appVersion: options.appVersion || "1.0.0",
    endpoint: options.endpoint || "/api/analytics/events",
    platform: "mobile",
    enableAutoPageView: false,
    debug: options.debug ?? false
    // adapter 需要由调用者提供
  };
}
function createMiniappConfig(appId, options = {}) {
  return {
    appId,
    appVersion: options.appVersion || "1.0.0",
    endpoint: options.endpoint || "/api/analytics/events",
    platform: "miniapp",
    enableAutoPageView: true,
    debug: options.debug ?? false
    // adapter 需要由调用者提供
  };
}
function createDesktopConfig(appId, options = {}) {
  return {
    appId,
    appVersion: options.appVersion || "1.0.0",
    endpoint: options.endpoint || "/api/analytics/events",
    platform: "desktop",
    enableAutoPageView: false,
    debug: options.debug ?? false
    // adapter 需要由调用者提供
  };
}

// src/analytics/client/singleton.ts
var instances = /* @__PURE__ */ new Map();
function createAnalytics(instanceKey, config) {
  if (!instances.has(instanceKey)) {
    instances.set(instanceKey, new Analytics(config));
  }
  return instances.get(instanceKey);
}
function getAnalyticsInstance(instanceKey) {
  return instances.get(instanceKey) || null;
}
function resetAnalytics(instanceKey) {
  instances.delete(instanceKey);
}
function resetAllAnalytics() {
  instances.clear();
}
function isAnalyticsInitialized(instanceKey) {
  return instances.has(instanceKey);
}
function getAllInstanceKeys() {
  return Array.from(instances.keys());
}

// src/analytics/utils/helpers.ts
function throttle(func, wait) {
  let timeout = null;
  let previous = 0;
  return function(...args) {
    const now = Date.now();
    const remaining = wait - (now - previous);
    if (remaining <= 0 || remaining > wait) {
      if (timeout) {
        clearTimeout(timeout);
        timeout = null;
      }
      previous = now;
      func.apply(this, args);
    } else if (!timeout) {
      timeout = setTimeout(() => {
        previous = Date.now();
        timeout = null;
        func.apply(this, args);
      }, remaining);
    }
  };
}
function debounce(func, wait) {
  let timeout = null;
  return function(...args) {
    if (timeout) {
      clearTimeout(timeout);
    }
    timeout = setTimeout(() => {
      func.apply(this, args);
    }, wait);
  };
}
function formatEvent(event) {
  return JSON.stringify(event, null, 2);
}
function validateEvent(event) {
  if (!event.event_id || !event.event_type || !event.event_name) {
    return false;
  }
  if (!event.timestamp || event.timestamp <= 0) {
    return false;
  }
  if (!event.session_id || !event.device_id) {
    return false;
  }
  return true;
}
function validateEvents(events) {
  const valid = [];
  const invalid = [];
  events.forEach((event) => {
    if (validateEvent(event)) {
      valid.push(event);
    } else {
      invalid.push(event);
    }
  });
  return { valid, invalid };
}
function getEventSize(event) {
  return new Blob([JSON.stringify(event)]).size;
}
function getBatchSize(events) {
  return events.reduce((total, event) => total + getEventSize(event), 0);
}
function sanitizeEvent(event, sensitiveKeys = ["password", "token", "secret", "key"]) {
  const sanitized = { ...event };
  if (sanitized.properties) {
    const cleanProperties = { ...sanitized.properties };
    sensitiveKeys.forEach((key) => {
      if (key in cleanProperties) {
        cleanProperties[key] = "***";
      }
    });
    sanitized.properties = cleanProperties;
  }
  return sanitized;
}
function mergeEventProperties(baseProperties, ...additionalProperties) {
  return Object.assign({}, baseProperties, ...additionalProperties);
}
function generateUniqueId(prefix = "") {
  const timestamp = Date.now();
  const random = Math.random().toString(36).substring(2, 15);
  return prefix ? `${prefix}_${timestamp}_${random}` : `${timestamp}_${random}`;
}
function isMobile() {
  if (typeof navigator === "undefined") return false;
  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}
function isDevelopment() {
  return process.env.NODE_ENV === "development";
}
function formatTimestamp(timestamp, format = "datetime") {
  const date = new Date(timestamp);
  switch (format) {
    case "date":
      return date.toLocaleDateString();
    case "time":
      return date.toLocaleTimeString();
    case "datetime":
    default:
      return date.toLocaleString();
  }
}
function deepClone(obj) {
  return JSON.parse(JSON.stringify(obj));
}
function safeStringify(obj, fallback = "{}") {
  try {
    return JSON.stringify(obj);
  } catch (error) {
    console.error("Failed to stringify object:", error);
    return fallback;
  }
}
function safeParse(json, fallback) {
  try {
    return JSON.parse(json);
  } catch (error) {
    console.error("Failed to parse JSON:", error);
    return fallback;
  }
}
function getPageDuration(startTime) {
  return Date.now() - startTime;
}
function getCurrentPageUrl() {
  if (typeof window !== "undefined") {
    return window.location.href;
  }
  return "";
}
function getCurrentPageTitle() {
  if (typeof document !== "undefined") {
    return document.title;
  }
  return "";
}
function getReferrer() {
  if (typeof document !== "undefined") {
    return document.referrer;
  }
  return "";
}

// src/analytics/utils/decorators.ts
function Track(eventName, priority = 1 /* NORMAL */) {
  return function(_target, propertyKey, descriptor) {
    const originalMethod = descriptor.value;
    descriptor.value = async function(...args) {
      const analytics = getAnalyticsInstance2(this);
      const finalEventName = eventName || propertyKey;
      const startTime = Date.now();
      try {
        const result = await originalMethod.apply(this, args);
        analytics?.track(
          "custom" /* CUSTOM */,
          finalEventName,
          {
            success: true,
            duration: Date.now() - startTime,
            args: JSON.stringify(args)
          },
          priority
        );
        return result;
      } catch (error) {
        analytics?.track(
          "error" /* ERROR */,
          `${finalEventName}_error`,
          {
            success: false,
            duration: Date.now() - startTime,
            error: error instanceof Error ? error.message : String(error)
          },
          2 /* HIGH */
        );
        throw error;
      }
    };
    return descriptor;
  };
}
function TrackClick(eventName) {
  return function(_target, propertyKey, descriptor) {
    const originalMethod = descriptor.value;
    descriptor.value = function(...args) {
      const analytics = getAnalyticsInstance2(this);
      const finalEventName = eventName || propertyKey;
      analytics?.track(
        "click" /* CLICK */,
        finalEventName,
        {
          args: JSON.stringify(args)
        },
        0 /* LOW */
      );
      return originalMethod.apply(this, args);
    };
    return descriptor;
  };
}
function TrackPerformance(metricName) {
  return function(_target, propertyKey, descriptor) {
    const originalMethod = descriptor.value;
    descriptor.value = async function(...args) {
      const analytics = getAnalyticsInstance2(this);
      const finalMetricName = metricName || propertyKey;
      const startTime = performance.now();
      try {
        const result = await originalMethod.apply(this, args);
        const duration = performance.now() - startTime;
        analytics?.trackPerformance(finalMetricName, duration, "ms", {
          success: true
        });
        return result;
      } catch (error) {
        const duration = performance.now() - startTime;
        analytics?.trackPerformance(finalMetricName, duration, "ms", {
          success: false,
          error: error instanceof Error ? error.message : String(error)
        });
        throw error;
      }
    };
    return descriptor;
  };
}
function CatchError(_eventName) {
  return function(_target, propertyKey, descriptor) {
    const originalMethod = descriptor.value;
    descriptor.value = async function(...args) {
      try {
        return await originalMethod.apply(this, args);
      } catch (error) {
        const analytics = getAnalyticsInstance2(this);
        analytics?.trackError(
          error instanceof Error ? error.message : String(error),
          error instanceof Error ? error.stack : void 0,
          error instanceof Error ? error.name : "Error",
          {
            method: propertyKey,
            args: JSON.stringify(args)
          }
        );
        throw error;
      }
    };
    return descriptor;
  };
}
function getAnalyticsInstance2(instance) {
  if (instance.analytics) {
    return instance.analytics;
  }
  if (instance._analytics) {
    return instance._analytics;
  }
  if (globalThis.__analytics__) {
    return globalThis.__analytics__;
  }
  return null;
}
function setGlobalAnalytics(analytics) {
  globalThis.__analytics__ = analytics;
}
function getGlobalAnalytics() {
  return globalThis.__analytics__ || null;
}
function useAnalytics(analytics) {
  return analytics;
}
function usePageView(analytics, pageUrl, pageTitle) {
  useEffect(() => {
    if (!analytics) return;
    const url = pageUrl || (typeof window !== "undefined" ? window.location.href : "");
    const title = pageTitle || (typeof document !== "undefined" ? document.title : "");
    analytics.trackPageView(url, title);
  }, [analytics, pageUrl, pageTitle]);
}
function useTrackEvent(analytics) {
  return useCallback(
    (eventType, eventName, properties, priority) => {
      if (analytics) {
        analytics.track(eventType, eventName, properties, priority);
      }
    },
    [analytics]
  );
}
function useTrackClick(analytics) {
  return useCallback(
    (elementInfo) => {
      if (analytics) {
        analytics.trackClick(elementInfo);
      }
    },
    [analytics]
  );
}
function usePageDuration(analytics) {
  const startTimeRef = useRef(Date.now());
  useEffect(() => {
    startTimeRef.current = Date.now();
    return () => {
      if (analytics) {
        const duration = Date.now() - startTimeRef.current;
        analytics.track(
          "page_leave" /* PAGE_LEAVE */,
          "page_leave",
          {
            duration,
            page_url: typeof window !== "undefined" ? window.location.href : ""
          },
          1 /* NORMAL */
        );
      }
    };
  }, [analytics]);
}
function usePerformanceTracking(analytics) {
  useEffect(() => {
    if (!analytics || typeof window === "undefined") return;
    if ("performance" in window && "timing" in window.performance) {
      const timing = window.performance.timing;
      const loadTime = timing.loadEventEnd - timing.navigationStart;
      const domReadyTime = timing.domContentLoadedEventEnd - timing.navigationStart;
      const firstPaintTime = timing.responseStart - timing.navigationStart;
      analytics.trackPerformance("page_load_time", loadTime, "ms");
      analytics.trackPerformance("dom_ready_time", domReadyTime, "ms");
      analytics.trackPerformance("first_paint_time", firstPaintTime, "ms");
    }
    if ("PerformanceObserver" in window) {
      const observer = new PerformanceObserver((list) => {
        list.getEntries().forEach((entry) => {
          if (entry.entryType === "resource") {
            analytics.trackPerformance("resource_load_time", entry.duration, "ms", {
              resource_name: entry.name
            });
          }
        });
      });
      observer.observe({ entryTypes: ["resource"] });
      return () => observer.disconnect();
    }
    return void 0;
  }, [analytics]);
}
function useErrorTracking(analytics) {
  useEffect(() => {
    if (!analytics || typeof window === "undefined") return;
    const handleError = (event) => {
      analytics.trackError(event.message, event.error?.stack, event.error?.name, {
        filename: event.filename,
        lineno: event.lineno,
        colno: event.colno
      });
    };
    const handleUnhandledRejection = (event) => {
      analytics.trackError("Unhandled Promise Rejection", void 0, "PromiseRejection", {
        reason: String(event.reason)
      });
    };
    window.addEventListener("error", handleError);
    window.addEventListener("unhandledrejection", handleUnhandledRejection);
    return () => {
      window.removeEventListener("error", handleError);
      window.removeEventListener("unhandledrejection", handleUnhandledRejection);
    };
  }, [analytics]);
}
function useAutoTracking(analytics, options = {}) {
  const {
    trackPageView = true,
    trackPageDuration = true,
    trackPerformance = true,
    trackErrors = true
  } = options;
  useEffect(() => {
    if (trackPageView && analytics) {
      const url = typeof window !== "undefined" ? window.location.href : "";
      const title = typeof document !== "undefined" ? document.title : "";
      analytics.trackPageView(url, title);
    }
  }, [analytics, trackPageView]);
  const startTimeRef = useRef(Date.now());
  useEffect(() => {
    if (!trackPageDuration || !analytics) return;
    startTimeRef.current = Date.now();
    return () => {
      const duration = Date.now() - startTimeRef.current;
      analytics.track(
        "page_leave" /* PAGE_LEAVE */,
        "page_leave",
        {
          duration,
          page_url: typeof window !== "undefined" ? window.location.href : ""
        },
        1 /* NORMAL */
      );
    };
  }, [analytics, trackPageDuration]);
  useEffect(() => {
    if (!trackPerformance || !analytics || typeof window === "undefined") return;
    const handleLoad = () => {
      if ("performance" in window && "timing" in window.performance) {
        const timing = window.performance.timing;
        const loadTime = timing.loadEventEnd - timing.navigationStart;
        analytics.trackPerformance("page_load_time", loadTime, "ms");
      }
    };
    window.addEventListener("load", handleLoad);
    return () => window.removeEventListener("load", handleLoad);
  }, [analytics, trackPerformance]);
  useEffect(() => {
    if (!trackErrors || !analytics || typeof window === "undefined") return;
    const handleError = (event) => {
      analytics.trackError(event.message, event.error?.stack, event.error?.name);
    };
    window.addEventListener("error", handleError);
    return () => window.removeEventListener("error", handleError);
  }, [analytics, trackErrors]);
}

// src/analytics/adapters/web.ts
var WebEventStorageAdapter = class {
  constructor() {
    this.storage = new WebStorageAdapter();
    this.EVENTS_KEY = "analytics:events";
    this.DEVICE_INFO_KEY = "analytics:device_info";
    this.SESSION_ID_KEY = "analytics:session_id";
  }
  async saveEvents(events) {
    try {
      await this.storage.setItem(this.EVENTS_KEY, JSON.stringify(events));
    } catch (error) {
      console.error("Failed to save events:", error);
    }
  }
  async getEvents() {
    try {
      const data = await this.storage.getItem(this.EVENTS_KEY);
      return data ? JSON.parse(data) : [];
    } catch (error) {
      console.error("Failed to get events:", error);
      return [];
    }
  }
  async clearEvents() {
    try {
      await this.storage.removeItem(this.EVENTS_KEY);
    } catch (error) {
      console.error("Failed to clear events:", error);
    }
  }
  async saveDeviceInfo(info) {
    try {
      await this.storage.setItem(this.DEVICE_INFO_KEY, JSON.stringify(info));
    } catch (error) {
      console.error("Failed to save device info:", error);
    }
  }
  async getDeviceInfo() {
    try {
      const data = await this.storage.getItem(this.DEVICE_INFO_KEY);
      return data ? JSON.parse(data) : null;
    } catch (error) {
      console.error("Failed to get device info:", error);
      return null;
    }
  }
  async saveSessionId(sessionId) {
    try {
      if (typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
        sessionStorage.setItem(this.SESSION_ID_KEY, sessionId);
      }
    } catch (error) {
      console.error("Failed to save session ID:", error);
    }
  }
  async getSessionId() {
    try {
      if (typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
        return sessionStorage.getItem(this.SESSION_ID_KEY);
      }
      return null;
    } catch (error) {
      console.error("Failed to get session ID:", error);
      return null;
    }
  }
};
var WebNetworkAdapter = class {
  async upload(url, events) {
    try {
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          events,
          timestamp: Date.now()
        }),
        // 使用 keepalive 确保页面关闭时也能发送
        keepalive: true
      });
      if (response.ok) {
        const data = await response.json();
        return {
          success: true,
          message: data.message,
          code: response.status
        };
      } else {
        return {
          success: false,
          message: `HTTP ${response.status}`,
          code: response.status
        };
      }
    } catch (error) {
      return {
        success: false,
        message: error instanceof Error ? error.message : "Network error",
        code: 0
      };
    }
  }
  async isOnline() {
    if (typeof navigator !== "undefined" && "onLine" in navigator) {
      return navigator.onLine;
    }
    return true;
  }
};
var WebDeviceAdapter = class {
  async getDeviceInfo() {
    return {
      device_id: await this.generateDeviceId(),
      os_name: this.getOSName(),
      os_version: this.getOSVersion(),
      screen_width: typeof window !== "undefined" ? window.screen.width : 0,
      screen_height: typeof window !== "undefined" ? window.screen.height : 0,
      language: typeof navigator !== "undefined" ? navigator.language : "en",
      timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
      device_model: this.getBrowserName(),
      device_brand: this.getBrowserVersion()
    };
  }
  async generateDeviceId() {
    if (typeof window !== "undefined") {
      let deviceId = localStorage.getItem("analytics:device_id");
      if (!deviceId) {
        deviceId = `web_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
        localStorage.setItem("analytics:device_id", deviceId);
      }
      return deviceId;
    }
    return `web_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
  }
  getOSName() {
    if (typeof navigator === "undefined") return "unknown";
    const userAgent = navigator.userAgent;
    if (userAgent.indexOf("Win") !== -1) return "Windows";
    if (userAgent.indexOf("Mac") !== -1) return "MacOS";
    if (userAgent.indexOf("Linux") !== -1) return "Linux";
    if (userAgent.indexOf("Android") !== -1) return "Android";
    if (userAgent.indexOf("iOS") !== -1) return "iOS";
    return "unknown";
  }
  getOSVersion() {
    if (typeof navigator === "undefined") return "unknown";
    const userAgent = navigator.userAgent;
    const match = userAgent.match(/\(([^)]+)\)/);
    return match && match[1] ? match[1] : "unknown";
  }
  getBrowserName() {
    if (typeof navigator === "undefined") return "unknown";
    const userAgent = navigator.userAgent;
    if (userAgent.indexOf("Chrome") !== -1) return "Chrome";
    if (userAgent.indexOf("Safari") !== -1) return "Safari";
    if (userAgent.indexOf("Firefox") !== -1) return "Firefox";
    if (userAgent.indexOf("Edge") !== -1) return "Edge";
    return "unknown";
  }
  getBrowserVersion() {
    if (typeof navigator === "undefined") return "unknown";
    const userAgent = navigator.userAgent;
    const match = userAgent.match(/(Chrome|Safari|Firefox|Edge)\/(\d+)/);
    return match && match[2] ? match[2] : "unknown";
  }
};
var webAdapter = {
  storage: new WebEventStorageAdapter(),
  network: new WebNetworkAdapter(),
  device: new WebDeviceAdapter()
};

// src/analytics/adapters/mobile.ts
var MobileEventStorageAdapter = class {
  // 需要注入具体的存储实现
  constructor(storage) {
    this.storage = storage;
    this.EVENTS_KEY = "@analytics:events";
    this.DEVICE_INFO_KEY = "@analytics:device_info";
    this.SESSION_ID_KEY = "@analytics:session_id";
  }
  async saveEvents(events) {
    try {
      await this.storage.setItem(this.EVENTS_KEY, JSON.stringify(events));
    } catch (error) {
      console.error("Failed to save events:", error);
    }
  }
  async getEvents() {
    try {
      const data = await this.storage.getItem(this.EVENTS_KEY);
      return data ? JSON.parse(data) : [];
    } catch (error) {
      console.error("Failed to get events:", error);
      return [];
    }
  }
  async clearEvents() {
    try {
      await this.storage.removeItem(this.EVENTS_KEY);
    } catch (error) {
      console.error("Failed to clear events:", error);
    }
  }
  async saveDeviceInfo(info) {
    try {
      await this.storage.setItem(this.DEVICE_INFO_KEY, JSON.stringify(info));
    } catch (error) {
      console.error("Failed to save device info:", error);
    }
  }
  async getDeviceInfo() {
    try {
      const data = await this.storage.getItem(this.DEVICE_INFO_KEY);
      return data ? JSON.parse(data) : null;
    } catch (error) {
      console.error("Failed to get device info:", error);
      return null;
    }
  }
  async saveSessionId(sessionId) {
    try {
      await this.storage.setItem(this.SESSION_ID_KEY, sessionId);
    } catch (error) {
      console.error("Failed to save session ID:", error);
    }
  }
  async getSessionId() {
    try {
      return await this.storage.getItem(this.SESSION_ID_KEY);
    } catch (error) {
      console.error("Failed to get session ID:", error);
      return null;
    }
  }
};
var MobileNetworkAdapter = class {
  // 需要注入网络检查函数
  constructor(netInfo) {
    this.netInfo = netInfo;
  }
  async upload(url, events) {
    try {
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          events,
          timestamp: Date.now()
        })
      });
      if (response.ok) {
        const data = await response.json();
        return {
          success: true,
          message: data.message,
          code: response.status
        };
      } else {
        return {
          success: false,
          message: `HTTP ${response.status}`,
          code: response.status
        };
      }
    } catch (error) {
      return {
        success: false,
        message: error instanceof Error ? error.message : "Network error",
        code: 0
      };
    }
  }
  async isOnline() {
    try {
      if (this.netInfo) {
        const state = await this.netInfo.fetch();
        return state.isConnected ?? false;
      }
      return true;
    } catch (error) {
      return true;
    }
  }
};
var MobileDeviceAdapter = class {
  // 需要注入设备信息获取函数
  constructor(deviceInfoModule) {
    this.deviceInfoModule = deviceInfoModule;
  }
  async getDeviceInfo() {
    try {
      const info = this.deviceInfoModule;
      return {
        device_id: info ? await info.getUniqueId() : await this.generateDeviceId(),
        device_model: info ? await info.getModel() : "unknown",
        device_brand: info ? await info.getBrand() : "unknown",
        os_name: info ? await info.getSystemName() : "unknown",
        os_version: info ? await info.getSystemVersion() : "unknown",
        screen_width: typeof window !== "undefined" ? window.screen.width : 0,
        screen_height: typeof window !== "undefined" ? window.screen.height : 0,
        language: typeof navigator !== "undefined" ? navigator.language : "en",
        timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
      };
    } catch (error) {
      console.error("Failed to get device info:", error);
      return this.getDefaultDeviceInfo();
    }
  }
  async generateDeviceId() {
    const timestamp = Date.now();
    const random = Math.random().toString(36).substring(2, 15);
    return `mobile_${timestamp}_${random}`;
  }
  getDefaultDeviceInfo() {
    return {
      device_id: `mobile_${Date.now()}`,
      os_name: "unknown",
      os_version: "unknown",
      screen_width: 0,
      screen_height: 0,
      language: "en",
      timezone: "UTC"
    };
  }
};
var MobileStorageAdapter = MobileEventStorageAdapter;

// src/analytics/adapters/miniapp.ts
var MiniappEventStorageAdapter = class {
  // 需要注入 Taro 的存储 API
  constructor(storage) {
    this.storage = storage;
    this.EVENTS_KEY = "analytics_events";
    this.DEVICE_INFO_KEY = "analytics_device_info";
    this.SESSION_ID_KEY = "analytics_session_id";
  }
  async saveEvents(events) {
    try {
      if (this.storage) {
        this.storage.setStorageSync(this.EVENTS_KEY, events);
      }
    } catch (error) {
      console.error("Failed to save events:", error);
    }
  }
  async getEvents() {
    try {
      if (this.storage) {
        const data = this.storage.getStorageSync(this.EVENTS_KEY);
        return data || [];
      }
      return [];
    } catch (error) {
      console.error("Failed to get events:", error);
      return [];
    }
  }
  async clearEvents() {
    try {
      if (this.storage) {
        this.storage.removeStorageSync(this.EVENTS_KEY);
      }
    } catch (error) {
      console.error("Failed to clear events:", error);
    }
  }
  async saveDeviceInfo(info) {
    try {
      if (this.storage) {
        this.storage.setStorageSync(this.DEVICE_INFO_KEY, info);
      }
    } catch (error) {
      console.error("Failed to save device info:", error);
    }
  }
  async getDeviceInfo() {
    try {
      if (this.storage) {
        return this.storage.getStorageSync(this.DEVICE_INFO_KEY) || null;
      }
      return null;
    } catch (error) {
      console.error("Failed to get device info:", error);
      return null;
    }
  }
  async saveSessionId(sessionId) {
    try {
      if (this.storage) {
        this.storage.setStorageSync(this.SESSION_ID_KEY, sessionId);
      }
    } catch (error) {
      console.error("Failed to save session ID:", error);
    }
  }
  async getSessionId() {
    try {
      if (this.storage) {
        return this.storage.getStorageSync(this.SESSION_ID_KEY) || null;
      }
      return null;
    } catch (error) {
      console.error("Failed to get session ID:", error);
      return null;
    }
  }
};
var MiniappNetworkAdapter = class {
  // 需要注入 Taro 的网络 API
  constructor(request, netInfo) {
    this.request = request;
    this.netInfo = netInfo;
  }
  async upload(url, events) {
    try {
      if (!this.request) {
        throw new Error("Request module not provided");
      }
      const response = await this.request.request({
        url,
        method: "POST",
        data: {
          events,
          timestamp: Date.now()
        },
        header: {
          "Content-Type": "application/json"
        }
      });
      if (response.statusCode === 200) {
        return {
          success: true,
          message: response.data.message,
          code: response.statusCode
        };
      } else {
        return {
          success: false,
          message: `HTTP ${response.statusCode}`,
          code: response.statusCode
        };
      }
    } catch (error) {
      return {
        success: false,
        message: error instanceof Error ? error.message : "Network error",
        code: 0
      };
    }
  }
  async isOnline() {
    try {
      if (this.netInfo) {
        const { networkType } = await this.netInfo.getNetworkType();
        return networkType !== "none";
      }
      return true;
    } catch (error) {
      return true;
    }
  }
};
var MiniappDeviceAdapter = class {
  // 需要注入 Taro 的系统信息 API
  constructor(systemInfo) {
    this.systemInfo = systemInfo;
  }
  async getDeviceInfo() {
    try {
      if (this.systemInfo) {
        const info = this.systemInfo.getSystemInfoSync();
        return {
          device_id: await this.generateDeviceId(),
          device_model: info.model || "unknown",
          device_brand: info.brand || "unknown",
          os_name: info.platform || "unknown",
          os_version: info.system || "unknown",
          screen_width: info.screenWidth || 0,
          screen_height: info.screenHeight || 0,
          language: info.language || "zh_CN",
          timezone: "Asia/Shanghai",
          network_type: info.networkType
        };
      }
      return this.getDefaultDeviceInfo();
    } catch (error) {
      console.error("Failed to get device info:", error);
      return this.getDefaultDeviceInfo();
    }
  }
  async generateDeviceId() {
    const timestamp = Date.now();
    const random = Math.random().toString(36).substring(2, 15);
    return `miniapp_${timestamp}_${random}`;
  }
  getDefaultDeviceInfo() {
    return {
      device_id: `miniapp_${Date.now()}`,
      os_name: "wechat",
      os_version: "unknown",
      screen_width: 0,
      screen_height: 0,
      language: "zh_CN",
      timezone: "Asia/Shanghai"
    };
  }
};
var MiniappStorageAdapter = MiniappEventStorageAdapter;

// src/analytics/adapters/desktop.ts
var DesktopEventStorageAdapter = class {
  constructor() {
    this.EVENTS_KEY = "analytics:events";
    this.DEVICE_INFO_KEY = "analytics:device_info";
    this.SESSION_ID_KEY = "analytics:session_id";
  }
  async saveEvents(events) {
    try {
      if (typeof window !== "undefined") {
        localStorage.setItem(this.EVENTS_KEY, JSON.stringify(events));
      }
    } catch (error) {
      console.error("Failed to save events:", error);
    }
  }
  async getEvents() {
    try {
      if (typeof window !== "undefined") {
        const data = localStorage.getItem(this.EVENTS_KEY);
        return data ? JSON.parse(data) : [];
      }
      return [];
    } catch (error) {
      console.error("Failed to get events:", error);
      return [];
    }
  }
  async clearEvents() {
    try {
      if (typeof window !== "undefined") {
        localStorage.removeItem(this.EVENTS_KEY);
      }
    } catch (error) {
      console.error("Failed to clear events:", error);
    }
  }
  async saveDeviceInfo(info) {
    try {
      if (typeof window !== "undefined") {
        localStorage.setItem(this.DEVICE_INFO_KEY, JSON.stringify(info));
      }
    } catch (error) {
      console.error("Failed to save device info:", error);
    }
  }
  async getDeviceInfo() {
    try {
      if (typeof window !== "undefined") {
        const data = localStorage.getItem(this.DEVICE_INFO_KEY);
        return data ? JSON.parse(data) : null;
      }
      return null;
    } catch (error) {
      console.error("Failed to get device info:", error);
      return null;
    }
  }
  async saveSessionId(sessionId) {
    try {
      if (typeof window !== "undefined") {
        localStorage.setItem(this.SESSION_ID_KEY, sessionId);
      }
    } catch (error) {
      console.error("Failed to save session ID:", error);
    }
  }
  async getSessionId() {
    try {
      if (typeof window !== "undefined") {
        return localStorage.getItem(this.SESSION_ID_KEY);
      }
      return null;
    } catch (error) {
      console.error("Failed to get session ID:", error);
      return null;
    }
  }
};
var DesktopNetworkAdapter = class {
  async upload(url, events) {
    try {
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          events,
          timestamp: Date.now()
        })
      });
      if (response.ok) {
        const data = await response.json();
        return {
          success: true,
          message: data.message,
          code: response.status
        };
      } else {
        return {
          success: false,
          message: `HTTP ${response.status}`,
          code: response.status
        };
      }
    } catch (error) {
      return {
        success: false,
        message: error instanceof Error ? error.message : "Network error",
        code: 0
      };
    }
  }
  async isOnline() {
    if (typeof navigator !== "undefined" && "onLine" in navigator) {
      return navigator.onLine;
    }
    return true;
  }
};
var DesktopDeviceAdapter = class {
  async getDeviceInfo() {
    return {
      device_id: await this.generateDeviceId(),
      os_name: this.getOSName(),
      os_version: this.getOSVersion(),
      screen_width: typeof window !== "undefined" ? window.screen.width : 0,
      screen_height: typeof window !== "undefined" ? window.screen.height : 0,
      language: typeof navigator !== "undefined" ? navigator.language : "en",
      timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
      device_model: "Desktop",
      device_brand: "Electron"
    };
  }
  async generateDeviceId() {
    if (typeof window !== "undefined") {
      let deviceId = localStorage.getItem("analytics:device_id");
      if (!deviceId) {
        deviceId = `desktop_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
        localStorage.setItem("analytics:device_id", deviceId);
      }
      return deviceId;
    }
    return `desktop_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
  }
  getOSName() {
    if (typeof navigator === "undefined") return "unknown";
    const platform = navigator.platform.toLowerCase();
    if (platform.indexOf("win") !== -1) return "Windows";
    if (platform.indexOf("mac") !== -1) return "MacOS";
    if (platform.indexOf("linux") !== -1) return "Linux";
    return "unknown";
  }
  getOSVersion() {
    if (typeof navigator === "undefined") return "unknown";
    return navigator.userAgent;
  }
};
var DesktopStorageAdapter = DesktopEventStorageAdapter;
var StatCard = ({
  title,
  value,
  subtitle,
  icon,
  trend,
  className = ""
}) => {
  return /* @__PURE__ */ React5.createElement(
    "div",
    {
      className: `bg-white rounded-lg shadow-sm p-6 border border-gray-200 hover:shadow-md transition-shadow ${className}`
    },
    /* @__PURE__ */ React5.createElement("div", { className: "flex items-start justify-between" }, /* @__PURE__ */ React5.createElement("div", { className: "flex-1" }, /* @__PURE__ */ React5.createElement("p", { className: "text-sm font-medium text-gray-600 mb-1" }, title), /* @__PURE__ */ React5.createElement("p", { className: "text-3xl font-bold text-gray-900" }, value.toLocaleString()), subtitle && /* @__PURE__ */ React5.createElement("p", { className: "text-sm text-gray-500 mt-2" }, subtitle), trend && /* @__PURE__ */ React5.createElement("div", { className: "flex items-center mt-2" }, /* @__PURE__ */ React5.createElement(
      "span",
      {
        className: `text-sm font-medium ${trend.isPositive ? "text-green-600" : "text-red-600"}`
      },
      trend.isPositive ? "\u2191" : "\u2193",
      " ",
      Math.abs(trend.value),
      "%"
    ), /* @__PURE__ */ React5.createElement("span", { className: "text-sm text-gray-500 ml-2" }, "vs \u4E0A\u5468"))), icon && /* @__PURE__ */ React5.createElement("div", { className: "flex-shrink-0 bg-gradient-to-br from-purple-500 to-indigo-600 rounded-lg p-3" }, /* @__PURE__ */ React5.createElement("div", { className: "text-white text-2xl" }, icon)))
  );
};
var EventList = ({
  events,
  loading = false,
  onEventClick,
  className = ""
}) => {
  if (loading) {
    return /* @__PURE__ */ React5.createElement("div", { className: `bg-white rounded-lg shadow-sm p-6 ${className}` }, /* @__PURE__ */ React5.createElement("div", { className: "animate-pulse space-y-4" }, [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ React5.createElement("div", { key: i, className: "h-16 bg-gray-200 rounded" }))));
  }
  if (events.length === 0) {
    return /* @__PURE__ */ React5.createElement("div", { className: `bg-white rounded-lg shadow-sm p-12 text-center ${className}` }, /* @__PURE__ */ React5.createElement("div", { className: "text-gray-400 text-5xl mb-4" }, "\u{1F4CA}"), /* @__PURE__ */ React5.createElement("p", { className: "text-gray-600 text-lg font-medium" }, "\u6682\u65E0\u6570\u636E"), /* @__PURE__ */ React5.createElement("p", { className: "text-gray-500 text-sm mt-2" }, "\u5C1D\u8BD5\u8C03\u6574\u7B5B\u9009\u6761\u4EF6"));
  }
  const getPlatformColor = (platform) => {
    const colors = {
      web: "bg-blue-100 text-blue-800",
      mobile: "bg-green-100 text-green-800",
      miniapp: "bg-purple-100 text-purple-800",
      desktop: "bg-gray-100 text-gray-800"
    };
    return colors[platform] || "bg-gray-100 text-gray-800";
  };
  const getEventTypeColor = (eventType) => {
    const colors = {
      page_view: "bg-indigo-100 text-indigo-800",
      click: "bg-amber-100 text-amber-800",
      error: "bg-red-100 text-red-800",
      performance: "bg-cyan-100 text-cyan-800",
      api_call: "bg-emerald-100 text-emerald-800"
    };
    return colors[eventType] || "bg-gray-100 text-gray-800";
  };
  const formatTimestamp2 = (timestamp) => {
    const date = new Date(timestamp);
    const now = /* @__PURE__ */ new Date();
    const diff = now.getTime() - date.getTime();
    const minutes = Math.floor(diff / 6e4);
    const hours = Math.floor(minutes / 60);
    const days = Math.floor(hours / 24);
    if (minutes < 1) return "\u521A\u521A";
    if (minutes < 60) return `${minutes}\u5206\u949F\u524D`;
    if (hours < 24) return `${hours}\u5C0F\u65F6\u524D`;
    if (days < 7) return `${days}\u5929\u524D`;
    return date.toLocaleDateString("zh-CN");
  };
  return /* @__PURE__ */ React5.createElement("div", { className: `bg-white rounded-lg shadow-sm overflow-hidden ${className}` }, /* @__PURE__ */ React5.createElement("div", { className: "overflow-x-auto" }, /* @__PURE__ */ React5.createElement("table", { className: "min-w-full divide-y divide-gray-200" }, /* @__PURE__ */ React5.createElement("thead", { className: "bg-gray-50" }, /* @__PURE__ */ React5.createElement("tr", null, /* @__PURE__ */ React5.createElement("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" }, "\u4E8B\u4EF6"), /* @__PURE__ */ React5.createElement("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" }, "\u5E73\u53F0"), /* @__PURE__ */ React5.createElement("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" }, "\u9875\u9762"), /* @__PURE__ */ React5.createElement("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" }, "\u7528\u6237"), /* @__PURE__ */ React5.createElement("th", { className: "px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" }, "\u65F6\u95F4"), /* @__PURE__ */ React5.createElement("th", { className: "px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider" }, "\u64CD\u4F5C"))), /* @__PURE__ */ React5.createElement("tbody", { className: "bg-white divide-y divide-gray-200" }, events.map((event) => /* @__PURE__ */ React5.createElement(
    "tr",
    {
      key: event.id,
      className: "hover:bg-gray-50 cursor-pointer transition-colors",
      onClick: () => onEventClick?.(event)
    },
    /* @__PURE__ */ React5.createElement("td", { className: "px-6 py-4 whitespace-nowrap" }, /* @__PURE__ */ React5.createElement("div", { className: "flex flex-col" }, /* @__PURE__ */ React5.createElement(
      "span",
      {
        className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${getEventTypeColor(
          event.eventType
        )} w-fit mb-1`
      },
      event.eventType
    ), /* @__PURE__ */ React5.createElement("span", { className: "text-sm text-gray-900" }, event.eventName))),
    /* @__PURE__ */ React5.createElement("td", { className: "px-6 py-4 whitespace-nowrap" }, /* @__PURE__ */ React5.createElement(
      "span",
      {
        className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${getPlatformColor(
          event.platform
        )}`
      },
      event.platform
    )),
    /* @__PURE__ */ React5.createElement("td", { className: "px-6 py-4" }, /* @__PURE__ */ React5.createElement("div", { className: "text-sm text-gray-900 max-w-xs truncate" }, event.pageUrl || "-"), event.pageTitle && /* @__PURE__ */ React5.createElement("div", { className: "text-xs text-gray-500 max-w-xs truncate" }, event.pageTitle)),
    /* @__PURE__ */ React5.createElement("td", { className: "px-6 py-4 whitespace-nowrap" }, /* @__PURE__ */ React5.createElement("div", { className: "text-sm text-gray-900" }, event.userId || "\u6E38\u5BA2"), /* @__PURE__ */ React5.createElement("div", { className: "text-xs text-gray-500" }, event.deviceId.slice(0, 8), "...")),
    /* @__PURE__ */ React5.createElement("td", { className: "px-6 py-4 whitespace-nowrap" }, /* @__PURE__ */ React5.createElement("div", { className: "text-sm text-gray-900" }, formatTimestamp2(event.timestamp)), /* @__PURE__ */ React5.createElement("div", { className: "text-xs text-gray-500" }, new Date(event.timestamp).toLocaleTimeString("zh-CN"))),
    /* @__PURE__ */ React5.createElement("td", { className: "px-6 py-4 whitespace-nowrap text-right text-sm font-medium" }, /* @__PURE__ */ React5.createElement(
      "button",
      {
        onClick: (e) => {
          e.stopPropagation();
          onEventClick?.(event);
        },
        className: "text-indigo-600 hover:text-indigo-900"
      },
      "\u8BE6\u60C5"
    ))
  ))))));
};
var FilterPanel = ({
  onFilterChange,
  initialFilters = {},
  className = ""
}) => {
  const [filters, setFilters] = useState(initialFilters);
  const handleDatePreset = (preset) => {
    const now = /* @__PURE__ */ new Date();
    let startDate = /* @__PURE__ */ new Date();
    switch (preset) {
      case "today":
        startDate.setHours(0, 0, 0, 0);
        break;
      case "yesterday":
        startDate.setDate(now.getDate() - 1);
        startDate.setHours(0, 0, 0, 0);
        now.setDate(now.getDate() - 1);
        now.setHours(23, 59, 59, 999);
        break;
      case "week":
        startDate.setDate(now.getDate() - 7);
        break;
      case "month":
        startDate.setMonth(now.getMonth() - 1);
        break;
      default:
        return;
    }
    const newFilters = {
      ...filters,
      dateRange: {
        startDate: startDate.toISOString(),
        endDate: now.toISOString()
      }
    };
    setFilters(newFilters);
    onFilterChange(newFilters);
  };
  const handleFilterChange = (key, value) => {
    const newFilters = {
      ...filters,
      [key]: value || void 0
    };
    setFilters(newFilters);
    onFilterChange(newFilters);
  };
  const handleReset = () => {
    const emptyFilters = {};
    setFilters(emptyFilters);
    onFilterChange(emptyFilters);
  };
  return /* @__PURE__ */ React5.createElement("div", { className: `bg-white rounded-xl shadow-sm border border-gray-200 ${className}` }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center justify-between mb-4 p-4 bg-gradient-to-r from-gray-50 to-gray-100 -m-6 mb-4 rounded-t-xl border-b border-gray-200" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React5.createElement(
    "svg",
    {
      className: "w-5 h-5 text-indigo-600",
      fill: "none",
      stroke: "currentColor",
      viewBox: "0 0 24 24"
    },
    /* @__PURE__ */ React5.createElement(
      "path",
      {
        strokeLinecap: "round",
        strokeLinejoin: "round",
        strokeWidth: 2,
        d: "M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"
      }
    )
  ), /* @__PURE__ */ React5.createElement("h3", { className: "text-sm font-semibold text-gray-900" }, "\u7B5B\u9009\u6761\u4EF6")), /* @__PURE__ */ React5.createElement(
    "button",
    {
      onClick: handleReset,
      className: "text-xs px-3 py-1 text-gray-600 hover:text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors"
    },
    "\u91CD\u7F6E"
  )), /* @__PURE__ */ React5.createElement("div", { className: "p-4 space-y-4" }, /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("label", { className: "block text-xs font-semibold text-gray-700 mb-2" }, "\u65F6\u95F4\u8303\u56F4"), /* @__PURE__ */ React5.createElement("div", { className: "grid grid-cols-2 gap-2" }, [
    { label: "\u4ECA\u5929", value: "today" },
    { label: "\u6628\u5929", value: "yesterday" },
    { label: "7\u5929", value: "week" },
    { label: "30\u5929", value: "month" }
  ].map((preset) => /* @__PURE__ */ React5.createElement(
    "button",
    {
      key: preset.value,
      onClick: () => handleDatePreset(preset.value),
      className: "px-3 py-1.5 text-xs font-medium border border-gray-300 rounded-lg hover:bg-indigo-50 hover:border-indigo-500 hover:text-indigo-700 transition-colors"
    },
    preset.label
  )))), /* @__PURE__ */ React5.createElement("div", { className: "space-y-3" }, /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("label", { className: "block text-xs font-medium text-gray-700 mb-1.5" }, "\u5F00\u59CB\u65F6\u95F4"), /* @__PURE__ */ React5.createElement(
    "input",
    {
      type: "datetime-local",
      value: filters.dateRange?.startDate ? new Date(filters.dateRange.startDate).toISOString().slice(0, 16) : "",
      onChange: (e) => handleFilterChange("dateRange", {
        ...filters.dateRange,
        startDate: e.target.value ? new Date(e.target.value).toISOString() : void 0
      }),
      className: "w-full px-2 py-1.5 text-xs border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"
    }
  )), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("label", { className: "block text-xs font-medium text-gray-700 mb-1.5" }, "\u7ED3\u675F\u65F6\u95F4"), /* @__PURE__ */ React5.createElement(
    "input",
    {
      type: "datetime-local",
      value: filters.dateRange?.endDate ? new Date(filters.dateRange.endDate).toISOString().slice(0, 16) : "",
      onChange: (e) => handleFilterChange("dateRange", {
        ...filters.dateRange,
        endDate: e.target.value ? new Date(e.target.value).toISOString() : void 0
      }),
      className: "w-full px-2 py-1.5 text-xs border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"
    }
  ))), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("label", { className: "block text-xs font-semibold text-gray-700 mb-2" }, "\u4E8B\u4EF6\u7C7B\u578B"), /* @__PURE__ */ React5.createElement(
    "select",
    {
      value: filters.eventType || "",
      onChange: (e) => handleFilterChange("eventType", e.target.value),
      className: "w-full px-2 py-1.5 text-xs border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"
    },
    /* @__PURE__ */ React5.createElement("option", { value: "" }, "\u5168\u90E8"),
    /* @__PURE__ */ React5.createElement("option", { value: "page_view" }, "\u9875\u9762\u6D4F\u89C8"),
    /* @__PURE__ */ React5.createElement("option", { value: "click" }, "\u70B9\u51FB"),
    /* @__PURE__ */ React5.createElement("option", { value: "search" }, "\u641C\u7D22"),
    /* @__PURE__ */ React5.createElement("option", { value: "login" }, "\u767B\u5F55"),
    /* @__PURE__ */ React5.createElement("option", { value: "logout" }, "\u767B\u51FA"),
    /* @__PURE__ */ React5.createElement("option", { value: "error" }, "\u9519\u8BEF"),
    /* @__PURE__ */ React5.createElement("option", { value: "performance" }, "\u6027\u80FD"),
    /* @__PURE__ */ React5.createElement("option", { value: "api_call" }, "API \u8C03\u7528"),
    /* @__PURE__ */ React5.createElement("option", { value: "custom" }, "\u81EA\u5B9A\u4E49")
  )), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("label", { className: "block text-xs font-semibold text-gray-700 mb-2" }, "\u5E73\u53F0"), /* @__PURE__ */ React5.createElement(
    "select",
    {
      value: filters.platform || "",
      onChange: (e) => handleFilterChange("platform", e.target.value),
      className: "w-full px-2 py-1.5 text-xs border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"
    },
    /* @__PURE__ */ React5.createElement("option", { value: "" }, "\u5168\u90E8"),
    /* @__PURE__ */ React5.createElement("option", { value: "web" }, "Web"),
    /* @__PURE__ */ React5.createElement("option", { value: "mobile" }, "Mobile"),
    /* @__PURE__ */ React5.createElement("option", { value: "miniapp" }, "\u5C0F\u7A0B\u5E8F"),
    /* @__PURE__ */ React5.createElement("option", { value: "desktop" }, "Desktop")
  )), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("label", { className: "block text-xs font-semibold text-gray-700 mb-2" }, "\u7528\u6237ID"), /* @__PURE__ */ React5.createElement(
    "input",
    {
      type: "text",
      value: filters.userId || "",
      onChange: (e) => handleFilterChange("userId", e.target.value),
      placeholder: "\u8F93\u5165\u7528\u6237ID",
      className: "w-full px-2 py-1.5 text-xs border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 placeholder:text-gray-400"
    }
  ))), /* @__PURE__ */ React5.createElement("div", { className: "px-4 py-3 bg-gray-50 -mx-6 -mb-6 mt-4 rounded-b-xl border-t border-gray-200" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React5.createElement(
    "div",
    {
      className: `w-2 h-2 rounded-full ${Object.keys(filters).length > 0 ? "bg-green-500" : "bg-gray-300"}`
    }
  ), /* @__PURE__ */ React5.createElement("p", { className: "text-xs text-gray-600" }, Object.keys(filters).length === 0 ? "\u672A\u5E94\u7528\u7B5B\u9009" : `${Object.keys(filters).length} \u4E2A\u7B5B\u9009`))));
};
var PieChart = ({ data, title, className = "" }) => {
  const total = data.reduce((sum, item) => sum + item.value, 0);
  const colors = [
    "bg-blue-500",
    "bg-green-500",
    "bg-purple-500",
    "bg-yellow-500",
    "bg-pink-500",
    "bg-indigo-500",
    "bg-red-500",
    "bg-cyan-500"
  ];
  return /* @__PURE__ */ React5.createElement("div", { className: `bg-white rounded-lg shadow-sm p-6 ${className}` }, title && /* @__PURE__ */ React5.createElement("h3", { className: "text-lg font-semibold text-gray-900 mb-4" }, title), /* @__PURE__ */ React5.createElement("div", { className: "space-y-3" }, data.map((item, index) => {
    const percentage = total > 0 ? (item.value / total * 100).toFixed(1) : 0;
    return /* @__PURE__ */ React5.createElement("div", { key: index }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center justify-between text-sm mb-1" }, /* @__PURE__ */ React5.createElement("span", { className: "text-gray-700 font-medium" }, item.name), /* @__PURE__ */ React5.createElement("span", { className: "text-gray-600" }, item.value.toLocaleString(), " (", percentage, "%)")), /* @__PURE__ */ React5.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2" }, /* @__PURE__ */ React5.createElement(
      "div",
      {
        className: `h-2 rounded-full ${colors[index % colors.length]}`,
        style: { width: `${percentage}%` }
      }
    )));
  })));
};
var BarChart = ({ data, title, className = "" }) => {
  const maxValue = Math.max(...data.map((item) => item.value), 1);
  return /* @__PURE__ */ React5.createElement("div", { className: `bg-white rounded-lg shadow-sm p-6 ${className}` }, title && /* @__PURE__ */ React5.createElement("h3", { className: "text-lg font-semibold text-gray-900 mb-4" }, title), /* @__PURE__ */ React5.createElement("div", { className: "space-y-4" }, data.map((item, index) => {
    const percentage = item.value / maxValue * 100;
    return /* @__PURE__ */ React5.createElement("div", { key: index, className: "flex items-center gap-4" }, /* @__PURE__ */ React5.createElement("div", { className: "w-32 text-sm text-gray-700 font-medium truncate" }, item.name), /* @__PURE__ */ React5.createElement("div", { className: "flex-1 flex items-center gap-2" }, /* @__PURE__ */ React5.createElement("div", { className: "flex-1 bg-gray-200 rounded-full h-8 relative overflow-hidden" }, /* @__PURE__ */ React5.createElement(
      "div",
      {
        className: "h-full bg-gradient-to-r from-indigo-500 to-purple-600 flex items-center justify-end px-3",
        style: { width: `${percentage}%`, minWidth: "40px" }
      },
      /* @__PURE__ */ React5.createElement("span", { className: "text-xs text-white font-semibold" }, item.value.toLocaleString())
    ))));
  })));
};
var AnalyticsDashboard = ({
  apiBaseUrl = "/api/analytics",
  className = ""
}) => {
  const [stats, setStats] = useState(null);
  const [events, setEvents] = useState([]);
  const [filters, setFilters] = useState({});
  const [loading, setLoading] = useState(true);
  const [selectedEvent, setSelectedEvent] = useState(null);
  const [currentPage, setCurrentPage] = useState(1);
  const [totalEvents, setTotalEvents] = useState(0);
  const pageSize = 20;
  const loadStats = async () => {
    try {
      const params = new URLSearchParams();
      if (filters.dateRange?.startDate) {
        params.append("startDate", filters.dateRange.startDate);
      }
      if (filters.dateRange?.endDate) {
        params.append("endDate", filters.dateRange.endDate);
      }
      if (filters.platform) {
        params.append("platform", filters.platform);
      }
      const response = await fetch(`${apiBaseUrl}/stats?${params}`);
      const data = await response.json();
      if (data.success) {
        setStats(data.data);
      }
    } catch (error) {
      console.error("Failed to load stats:", error);
    }
  };
  const loadEvents = async () => {
    try {
      setLoading(true);
      const params = new URLSearchParams();
      if (filters.dateRange?.startDate) {
        params.append("startDate", filters.dateRange.startDate);
      }
      if (filters.dateRange?.endDate) {
        params.append("endDate", filters.dateRange.endDate);
      }
      if (filters.eventType) {
        params.append("eventType", filters.eventType);
      }
      if (filters.platform) {
        params.append("platform", filters.platform);
      }
      if (filters.userId) {
        params.append("userId", filters.userId);
      }
      params.append("limit", pageSize.toString());
      params.append("offset", ((currentPage - 1) * pageSize).toString());
      params.append("orderBy", "timestamp");
      params.append("orderDirection", "desc");
      const response = await fetch(`${apiBaseUrl}/query?${params}`);
      const data = await response.json();
      if (data.success) {
        setEvents(data.data);
        setTotalEvents(data.total);
      }
    } catch (error) {
      console.error("Failed to load events:", error);
    } finally {
      setLoading(false);
    }
  };
  useEffect(() => {
    loadStats();
    loadEvents();
  }, [filters, currentPage]);
  const handleFilterChange = (newFilters) => {
    setFilters(newFilters);
    setCurrentPage(1);
  };
  const handleEventClick = (event) => {
    setSelectedEvent(event);
  };
  const closeEventDetail = () => {
    setSelectedEvent(null);
  };
  const totalPages = Math.ceil(totalEvents / pageSize);
  return /* @__PURE__ */ React5.createElement("div", { className: `space-y-6 ${className}` }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-3" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2 text-sm text-gray-600" }, /* @__PURE__ */ React5.createElement(
    "svg",
    {
      className: "w-5 h-5 text-indigo-600",
      fill: "none",
      stroke: "currentColor",
      viewBox: "0 0 24 24"
    },
    /* @__PURE__ */ React5.createElement(
      "path",
      {
        strokeLinecap: "round",
        strokeLinejoin: "round",
        strokeWidth: 2,
        d: "M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"
      }
    )
  ), /* @__PURE__ */ React5.createElement("span", { className: "font-medium" }, "\u5B9E\u65F6\u6570\u636E\u76D1\u63A7")), totalEvents > 0 && /* @__PURE__ */ React5.createElement("span", { className: "text-xs px-2 py-1 bg-indigo-100 text-indigo-700 rounded-full font-medium" }, totalEvents.toLocaleString(), " \u6761\u8BB0\u5F55")), /* @__PURE__ */ React5.createElement(
    "button",
    {
      onClick: () => {
        loadStats();
        loadEvents();
      },
      className: "flex items-center gap-2 px-4 py-2 text-sm bg-gradient-to-r from-indigo-600 to-purple-600 text-white rounded-lg hover:from-indigo-700 hover:to-purple-700 transition-all duration-200 shadow-sm hover:shadow-md"
    },
    /* @__PURE__ */ React5.createElement("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" }, /* @__PURE__ */ React5.createElement(
      "path",
      {
        strokeLinecap: "round",
        strokeLinejoin: "round",
        strokeWidth: 2,
        d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
      }
    )),
    /* @__PURE__ */ React5.createElement("span", null, "\u5237\u65B0\u6570\u636E")
  )), /* @__PURE__ */ React5.createElement("div", { className: "grid grid-cols-12 gap-6" }, /* @__PURE__ */ React5.createElement("div", { className: "col-span-12 xl:col-span-3" }, /* @__PURE__ */ React5.createElement(FilterPanel, { onFilterChange: handleFilterChange, initialFilters: filters })), /* @__PURE__ */ React5.createElement("div", { className: "col-span-12 xl:col-span-9 space-y-6" }, loading && !stats ? /* @__PURE__ */ React5.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4" }, [1, 2, 3, 4].map((i) => /* @__PURE__ */ React5.createElement(
    "div",
    {
      key: i,
      className: "bg-white rounded-xl shadow-sm border border-gray-200 p-6 animate-pulse"
    },
    /* @__PURE__ */ React5.createElement("div", { className: "h-4 bg-gray-200 rounded w-20 mb-3" }),
    /* @__PURE__ */ React5.createElement("div", { className: "h-8 bg-gray-200 rounded w-24 mb-2" }),
    /* @__PURE__ */ React5.createElement("div", { className: "h-3 bg-gray-200 rounded w-16" })
  ))) : stats ? /* @__PURE__ */ React5.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4 animate-fade-in" }, /* @__PURE__ */ React5.createElement(
    StatCard,
    {
      title: "\u603B\u4E8B\u4EF6\u6570",
      value: stats.totalEvents,
      subtitle: "\u6240\u6709\u5E73\u53F0",
      icon: "\u{1F4C8}",
      className: "hover:scale-105 transition-transform duration-200"
    }
  ), /* @__PURE__ */ React5.createElement(
    StatCard,
    {
      title: "\u72EC\u7ACB\u7528\u6237",
      value: stats.uniqueUsers,
      subtitle: "\u53BB\u91CD\u7EDF\u8BA1",
      icon: "\u{1F465}",
      className: "hover:scale-105 transition-transform duration-200"
    }
  ), /* @__PURE__ */ React5.createElement(
    StatCard,
    {
      title: "\u4F1A\u8BDD\u6570",
      value: stats.uniqueSessions,
      subtitle: "\u7528\u6237\u4F1A\u8BDD",
      icon: "\u{1F517}",
      className: "hover:scale-105 transition-transform duration-200"
    }
  ), /* @__PURE__ */ React5.createElement(
    StatCard,
    {
      title: "\u8BBE\u5907\u6570",
      value: stats.uniqueDevices,
      subtitle: "\u72EC\u7ACB\u8BBE\u5907",
      icon: "\u{1F4F1}",
      className: "hover:scale-105 transition-transform duration-200"
    }
  )) : null, stats && /* @__PURE__ */ React5.createElement("div", { className: "space-y-6 animate-fade-in" }, /* @__PURE__ */ React5.createElement("div", { className: "grid grid-cols-1 xl:grid-cols-2 gap-6" }, /* @__PURE__ */ React5.createElement("div", { className: "transform hover:scale-[1.02] transition-transform duration-200" }, /* @__PURE__ */ React5.createElement(
    PieChart,
    {
      title: "\u5E73\u53F0\u5206\u5E03",
      data: stats.eventsByPlatform.map((item) => ({
        name: item.platform,
        value: item.count
      }))
    }
  )), /* @__PURE__ */ React5.createElement("div", { className: "transform hover:scale-[1.02] transition-transform duration-200" }, /* @__PURE__ */ React5.createElement(
    BarChart,
    {
      title: "\u4E8B\u4EF6\u7C7B\u578B Top 10",
      data: stats.eventsByType.slice(0, 10).map((item) => ({
        name: item.eventType,
        value: item.count
      }))
    }
  ))), stats.topPages.length > 0 && /* @__PURE__ */ React5.createElement("div", { className: "transform hover:scale-[1.02] transition-transform duration-200" }, /* @__PURE__ */ React5.createElement(
    BarChart,
    {
      title: "\u70ED\u95E8\u9875\u9762 Top 10",
      data: stats.topPages.slice(0, 10).map((item) => ({
        name: item.pageUrl,
        value: item.count
      }))
    }
  ))), /* @__PURE__ */ React5.createElement("div", { className: "space-y-4" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ React5.createElement("h3", { className: "text-lg font-semibold text-gray-900 flex items-center gap-2" }, /* @__PURE__ */ React5.createElement(
    "svg",
    {
      className: "w-5 h-5 text-indigo-600",
      fill: "none",
      stroke: "currentColor",
      viewBox: "0 0 24 24"
    },
    /* @__PURE__ */ React5.createElement(
      "path",
      {
        strokeLinecap: "round",
        strokeLinejoin: "round",
        strokeWidth: 2,
        d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"
      }
    )
  ), "\u4E8B\u4EF6\u8BB0\u5F55"), totalEvents > 0 && !loading && /* @__PURE__ */ React5.createElement("span", { className: "text-sm text-gray-500" }, "\u663E\u793A ", (currentPage - 1) * pageSize + 1, "-", Math.min(currentPage * pageSize, totalEvents), " / ", totalEvents.toLocaleString())), /* @__PURE__ */ React5.createElement("div", { className: "animate-fade-in" }, /* @__PURE__ */ React5.createElement(EventList, { events, loading, onEventClick: handleEventClick })), totalPages > 1 && /* @__PURE__ */ React5.createElement("div", { className: "flex items-center justify-between bg-gradient-to-r from-gray-50 to-gray-100 px-6 py-4 rounded-xl border border-gray-200" }, /* @__PURE__ */ React5.createElement("div", { className: "hidden sm:block text-sm text-gray-600" }, "\u7B2C ", /* @__PURE__ */ React5.createElement("span", { className: "font-semibold text-gray-900" }, currentPage), " \u9875\uFF0C\u5171", " ", /* @__PURE__ */ React5.createElement("span", { className: "font-semibold text-gray-900" }, totalPages), " \u9875"), /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React5.createElement(
    "button",
    {
      onClick: () => setCurrentPage((p) => Math.max(1, p - 1)),
      disabled: currentPage === 1,
      className: "flex items-center gap-1 px-4 py-2 text-sm font-medium bg-white border border-gray-300 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50 hover:border-indigo-500 transition-all duration-200"
    },
    /* @__PURE__ */ React5.createElement("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" }, /* @__PURE__ */ React5.createElement(
      "path",
      {
        strokeLinecap: "round",
        strokeLinejoin: "round",
        strokeWidth: 2,
        d: "M15 19l-7-7 7-7"
      }
    )),
    /* @__PURE__ */ React5.createElement("span", { className: "hidden sm:inline" }, "\u4E0A\u4E00\u9875")
  ), /* @__PURE__ */ React5.createElement("div", { className: "sm:hidden px-4 py-2 text-sm text-gray-600" }, currentPage, " / ", totalPages), /* @__PURE__ */ React5.createElement(
    "button",
    {
      onClick: () => setCurrentPage((p) => Math.min(totalPages, p + 1)),
      disabled: currentPage === totalPages,
      className: "flex items-center gap-1 px-4 py-2 text-sm font-medium bg-white border border-gray-300 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50 hover:border-indigo-500 transition-all duration-200"
    },
    /* @__PURE__ */ React5.createElement("span", { className: "hidden sm:inline" }, "\u4E0B\u4E00\u9875"),
    /* @__PURE__ */ React5.createElement("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" }, /* @__PURE__ */ React5.createElement(
      "path",
      {
        strokeLinecap: "round",
        strokeLinejoin: "round",
        strokeWidth: 2,
        d: "M9 5l7 7-7 7"
      }
    ))
  )))))), selectedEvent && /* @__PURE__ */ React5.createElement(
    "div",
    {
      className: "fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-fade-in",
      onClick: closeEventDetail
    },
    /* @__PURE__ */ React5.createElement(
      "div",
      {
        className: "bg-white rounded-2xl shadow-2xl max-w-3xl w-full max-h-[85vh] overflow-hidden animate-slide-up",
        onClick: (e) => e.stopPropagation()
      },
      /* @__PURE__ */ React5.createElement("div", { className: "bg-gradient-to-r from-indigo-600 to-purple-600 px-6 py-4 flex items-center justify-between" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-3 text-white" }, /* @__PURE__ */ React5.createElement("svg", { className: "w-6 h-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" }, /* @__PURE__ */ React5.createElement(
        "path",
        {
          strokeLinecap: "round",
          strokeLinejoin: "round",
          strokeWidth: 2,
          d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
        }
      )), /* @__PURE__ */ React5.createElement("h3", { className: "text-xl font-semibold" }, "\u4E8B\u4EF6\u8BE6\u60C5")), /* @__PURE__ */ React5.createElement(
        "button",
        {
          onClick: closeEventDetail,
          className: "text-white hover:bg-white hover:bg-opacity-20 rounded-full p-2 transition-all duration-200"
        },
        /* @__PURE__ */ React5.createElement("svg", { className: "w-6 h-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" }, /* @__PURE__ */ React5.createElement(
          "path",
          {
            strokeLinecap: "round",
            strokeLinejoin: "round",
            strokeWidth: 2,
            d: "M6 18L18 6M6 6l12 12"
          }
        ))
      )),
      /* @__PURE__ */ React5.createElement("div", { className: "p-6 overflow-auto max-h-[calc(85vh-80px)]" }, /* @__PURE__ */ React5.createElement("div", { className: "space-y-5" }, /* @__PURE__ */ React5.createElement("div", { className: "bg-gradient-to-br from-blue-50 to-indigo-50 rounded-xl p-4 border border-blue-200" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2 mb-3" }, /* @__PURE__ */ React5.createElement(
        "svg",
        {
          className: "w-5 h-5 text-indigo-600",
          fill: "none",
          stroke: "currentColor",
          viewBox: "0 0 24 24"
        },
        /* @__PURE__ */ React5.createElement(
          "path",
          {
            strokeLinecap: "round",
            strokeLinejoin: "round",
            strokeWidth: 2,
            d: "M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"
          }
        )
      ), /* @__PURE__ */ React5.createElement("h4", { className: "font-semibold text-gray-900" }, "\u57FA\u7840\u4FE1\u606F")), /* @__PURE__ */ React5.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600" }, "\u4E8B\u4EF6ID"), /* @__PURE__ */ React5.createElement("code", { className: "text-xs bg-white px-2 py-1 rounded border border-blue-200 font-mono text-gray-800" }, selectedEvent.id.slice(0, 16), "...")), /* @__PURE__ */ React5.createElement("div", { className: "grid grid-cols-2 gap-3 pt-2" }, /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u4E8B\u4EF6\u7C7B\u578B"), /* @__PURE__ */ React5.createElement("span", { className: "inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-indigo-100 text-indigo-800" }, selectedEvent.eventType)), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u4E8B\u4EF6\u540D\u79F0"), /* @__PURE__ */ React5.createElement("p", { className: "text-sm font-medium text-gray-900 truncate" }, selectedEvent.eventName))))), /* @__PURE__ */ React5.createElement("div", { className: "grid grid-cols-2 gap-4" }, /* @__PURE__ */ React5.createElement("div", { className: "bg-gray-50 rounded-lg p-3 border border-gray-200" }, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u5E73\u53F0"), /* @__PURE__ */ React5.createElement("p", { className: "text-sm font-semibold text-gray-900" }, selectedEvent.platform)), /* @__PURE__ */ React5.createElement("div", { className: "bg-gray-50 rounded-lg p-3 border border-gray-200" }, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u5E94\u7528\u7248\u672C"), /* @__PURE__ */ React5.createElement("p", { className: "text-sm font-semibold text-gray-900" }, selectedEvent.appVersion))), /* @__PURE__ */ React5.createElement("div", { className: "bg-gradient-to-br from-purple-50 to-pink-50 rounded-xl p-4 border border-purple-200" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2 mb-3" }, /* @__PURE__ */ React5.createElement(
        "svg",
        {
          className: "w-5 h-5 text-purple-600",
          fill: "none",
          stroke: "currentColor",
          viewBox: "0 0 24 24"
        },
        /* @__PURE__ */ React5.createElement(
          "path",
          {
            strokeLinecap: "round",
            strokeLinejoin: "round",
            strokeWidth: 2,
            d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
          }
        )
      ), /* @__PURE__ */ React5.createElement("h4", { className: "font-semibold text-gray-900" }, "\u7528\u6237\u4FE1\u606F")), /* @__PURE__ */ React5.createElement("div", { className: "grid grid-cols-2 gap-3" }, /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u7528\u6237ID"), /* @__PURE__ */ React5.createElement("p", { className: "text-sm font-medium text-gray-900" }, selectedEvent.userId || /* @__PURE__ */ React5.createElement("span", { className: "text-gray-400" }, "\u6E38\u5BA2"))), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u4F1A\u8BDDID"), /* @__PURE__ */ React5.createElement("code", { className: "text-xs bg-white px-2 py-1 rounded border border-purple-200 font-mono text-gray-800 block truncate" }, selectedEvent.sessionId.slice(0, 12), "..."))), /* @__PURE__ */ React5.createElement("div", { className: "mt-3 pt-3 border-t border-purple-200" }, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u8BBE\u5907ID"), /* @__PURE__ */ React5.createElement("code", { className: "text-xs bg-white px-2 py-1 rounded border border-purple-200 font-mono text-gray-800 block truncate" }, selectedEvent.deviceId))), (selectedEvent.pageUrl || selectedEvent.pageTitle) && /* @__PURE__ */ React5.createElement("div", { className: "bg-gradient-to-br from-green-50 to-emerald-50 rounded-xl p-4 border border-green-200" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2 mb-3" }, /* @__PURE__ */ React5.createElement(
        "svg",
        {
          className: "w-5 h-5 text-green-600",
          fill: "none",
          stroke: "currentColor",
          viewBox: "0 0 24 24"
        },
        /* @__PURE__ */ React5.createElement(
          "path",
          {
            strokeLinecap: "round",
            strokeLinejoin: "round",
            strokeWidth: 2,
            d: "M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"
          }
        )
      ), /* @__PURE__ */ React5.createElement("h4", { className: "font-semibold text-gray-900" }, "\u9875\u9762\u4FE1\u606F")), selectedEvent.pageTitle && /* @__PURE__ */ React5.createElement("div", { className: "mb-2" }, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u9875\u9762\u6807\u9898"), /* @__PURE__ */ React5.createElement("p", { className: "text-sm font-medium text-gray-900" }, selectedEvent.pageTitle)), selectedEvent.pageUrl && /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("span", { className: "text-xs font-medium text-gray-600 block mb-1" }, "\u9875\u9762URL"), /* @__PURE__ */ React5.createElement("code", { className: "text-xs bg-white px-2 py-1 rounded border border-green-200 font-mono text-gray-800 block break-all" }, selectedEvent.pageUrl))), /* @__PURE__ */ React5.createElement("div", { className: "bg-gradient-to-br from-amber-50 to-yellow-50 rounded-xl p-4 border border-amber-200" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2 mb-2" }, /* @__PURE__ */ React5.createElement(
        "svg",
        {
          className: "w-5 h-5 text-amber-600",
          fill: "none",
          stroke: "currentColor",
          viewBox: "0 0 24 24"
        },
        /* @__PURE__ */ React5.createElement(
          "path",
          {
            strokeLinecap: "round",
            strokeLinejoin: "round",
            strokeWidth: 2,
            d: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
          }
        )
      ), /* @__PURE__ */ React5.createElement("h4", { className: "font-semibold text-gray-900" }, "\u65F6\u95F4\u4FE1\u606F")), /* @__PURE__ */ React5.createElement("p", { className: "text-sm font-medium text-gray-900" }, new Date(selectedEvent.timestamp).toLocaleString("zh-CN", {
        year: "numeric",
        month: "long",
        day: "numeric",
        hour: "2-digit",
        minute: "2-digit",
        second: "2-digit"
      }))), selectedEvent.properties && Object.keys(selectedEvent.properties).length > 0 && /* @__PURE__ */ React5.createElement("div", { className: "bg-gradient-to-br from-gray-50 to-slate-50 rounded-xl p-4 border border-gray-300" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2 mb-3" }, /* @__PURE__ */ React5.createElement(
        "svg",
        {
          className: "w-5 h-5 text-gray-600",
          fill: "none",
          stroke: "currentColor",
          viewBox: "0 0 24 24"
        },
        /* @__PURE__ */ React5.createElement(
          "path",
          {
            strokeLinecap: "round",
            strokeLinejoin: "round",
            strokeWidth: 2,
            d: "M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"
          }
        )
      ), /* @__PURE__ */ React5.createElement("h4", { className: "font-semibold text-gray-900" }, "\u81EA\u5B9A\u4E49\u5C5E\u6027")), /* @__PURE__ */ React5.createElement("pre", { className: "text-xs bg-white p-4 rounded-lg border border-gray-200 overflow-auto max-h-48 font-mono text-gray-800" }, JSON.stringify(selectedEvent.properties, null, 2)))))
    )
  ));
};

// src/analytics/index.ts
var ANALYTICS_VERSION = "1.0.0";

export { ANALYTICS_VERSION, Analytics, AnalyticsDashboard, BarChart, CatchError, DesktopDeviceAdapter, DesktopEventStorageAdapter, DesktopNetworkAdapter, DesktopStorageAdapter, EventList, EventPriority, EventQueue, EventType, FilterPanel, MiniappDeviceAdapter, MiniappEventStorageAdapter, MiniappNetworkAdapter, MiniappStorageAdapter, MobileDeviceAdapter, MobileEventStorageAdapter, MobileNetworkAdapter, MobileStorageAdapter, PieChart, StatCard, Track, TrackClick, TrackPerformance, Uploader, WebDeviceAdapter, WebEventStorageAdapter, WebNetworkAdapter, createAnalytics, createDesktopConfig, createMiniappConfig, createMobileConfig, createWebConfig, debounce, deepClone, formatEvent, formatTimestamp, generateUniqueId, getAllInstanceKeys, getAnalyticsInstance, getBatchSize, getCurrentPageTitle, getCurrentPageUrl, getEventSize, getGlobalAnalytics, getPageDuration, getReferrer, isAnalyticsInitialized, isDevelopment, isMobile, mergeEventProperties, resetAllAnalytics, resetAnalytics, safeParse, safeStringify, sanitizeEvent, setGlobalAnalytics, throttle, useAnalytics, useAutoTracking, useErrorTracking, usePageDuration, usePageView, usePerformanceTracking, useTrackClick, useTrackEvent, validateEvent, validateEvents, webAdapter };
//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map