var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/hardwareErrorTip/demo.tsx
var demo_exports = {};
__export(demo_exports, {
  default: () => demo_default
});
module.exports = __toCommonJS(demo_exports);
var import_react = __toESM(require("react"));
var import_index = __toESM(require("./index"));
var mockStatistics = {
  fatal: 1,
  critical: 2,
  normal: 3,
  info: 4
};
var mockErrors = [
  {
    error_level: 0,
    // 致命错误
    error_code: "ERR001",
    time: "2024-02-07 14:30:00",
    error_message: "打印机连接失败 - 端口CM3无响应",
    device: {
      device_type: "printer",
      device_name: "Xprinter 1234",
      device_idfa: "192.168.1.100"
    }
  },
  {
    error_level: 1,
    // 严重错误
    error_code: "ERR002",
    time: "2024-02-07 14:35:00",
    error_message: "扫码枪扫描异常",
    device: {
      device_type: "barcode_scanner",
      device_name: "Honeywell Scanner",
      device_idfa: "192.168.1.101"
    }
  },
  {
    error_level: 1,
    // 严重错误
    error_code: "ERR003",
    time: "2024-02-07 14:38:00",
    error_message: "CDS客显通信中断",
    device: {
      device_type: "cds",
      device_name: "CDS Display Pro",
      device_idfa: "192.168.1.102"
    }
  },
  {
    error_level: 2,
    // 一般错误
    error_code: "ERR004",
    time: "2024-02-07 14:40:00",
    error_message: "显示屏亮度调节失败",
    device: {
      device_type: "display",
      device_name: "Samsung Display",
      device_idfa: "192.168.1.103"
    }
  },
  {
    error_level: 2,
    // 一般错误
    error_code: "ERR005",
    time: "2024-02-07 14:42:00",
    error_message: "刷卡机读卡超时",
    device: {
      device_type: "card_reader",
      device_name: "PAX Card Reader",
      device_idfa: "192.168.1.104"
    }
  },
  {
    error_level: 2,
    // 一般错误
    error_code: "ERR006",
    time: "2024-02-07 14:43:00",
    error_message: "称重设备校准偏差",
    device: {
      device_type: "scale",
      device_name: "Electronic Scale",
      device_idfa: "192.168.1.105"
    }
  },
  {
    error_level: 3,
    // 提示信息
    error_code: "INFO001",
    time: "2024-02-07 14:45:00",
    error_message: "设备自检完成",
    device: {
      device_type: "printer",
      device_name: "Xprinter 1234",
      device_idfa: "192.168.1.100"
    }
  },
  {
    error_level: 3,
    // 提示信息
    error_code: "INFO002",
    time: "2024-02-07 14:46:00",
    error_message: "KDS厨显连接正常",
    device: {
      device_type: "kds",
      device_name: "Kitchen Display",
      device_idfa: "192.168.1.106"
    }
  },
  {
    error_level: 3,
    // 提示信息
    error_code: "INFO003",
    time: "2024-02-07 14:47:00",
    error_message: "钱箱状态正常",
    device: {
      device_type: "till",
      device_name: "Cash Drawer",
      device_idfa: "192.168.1.107"
    }
  },
  {
    error_level: 3,
    // 提示信息
    error_code: "INFO004",
    time: "2024-02-07 14:48:00",
    error_message: "系统启动完成",
    device: {
      device_type: "display",
      device_name: "Samsung Display",
      device_idfa: "192.168.1.103"
    }
  }
];
var mockLogs = [
  {
    log_level: 2,
    // 错误信息
    message: "打印机连接失败 - 端口CM3无响应",
    time: "2024-02-07 14:30:00",
    device: {
      device_type: "printer",
      device_name: "Xprinter 1234",
      device_idfa: "192.168.1.100"
    },
    data: JSON.stringify({
      operation: "打印操作",
      orderId: "ORDER123456",
      printerStatus: "OFFLINE"
    })
  },
  {
    log_level: 1,
    // 重要操作信息
    message: "开始打印任务",
    time: "2024-02-07 14:29:59",
    device: {
      device_type: "printer",
      device_name: "Xprinter 1234",
      device_idfa: "192.168.1.100"
    },
    data: JSON.stringify({
      operation: "打印操作",
      orderId: "ORDER123456",
      paperStatus: "OK"
    })
  },
  {
    log_level: 0,
    // 调试信息
    message: "检测到扫码枪连接",
    time: "2024-02-07 14:29:50",
    device: {
      device_type: "barcode_scanner",
      device_name: "Honeywell Scanner",
      device_idfa: "192.168.1.101"
    },
    data: JSON.stringify({
      connection: "USB",
      deviceId: "SCANNER_001",
      connectionStatus: "OK"
    })
  },
  {
    log_level: 2,
    // 错误信息
    message: "CDS客显通信中断",
    time: "2024-02-07 14:38:15",
    device: {
      device_type: "cds",
      device_name: "CDS Display Pro",
      device_idfa: "192.168.1.102"
    },
    data: JSON.stringify({
      operation: "显示更新",
      lastHeartbeat: "2024-02-07 14:37:45",
      connectionStatus: "TIMEOUT"
    })
  },
  {
    log_level: 2,
    // 错误信息
    message: "显示屏亮度调节失败",
    time: "2024-02-07 14:25:30",
    device: {
      device_type: "display",
      device_name: "Samsung Display",
      device_idfa: "192.168.1.103"
    },
    data: JSON.stringify({
      operation: "亮度调节",
      targetBrightness: 80,
      currentBrightness: 50,
      errorCode: "BRIGHTNESS_ADJUST_FAILED"
    })
  },
  {
    log_level: 1,
    // 重要操作信息
    message: "KDS厨显订单更新",
    time: "2024-02-07 14:20:15",
    device: {
      device_type: "kds",
      device_name: "Kitchen Display",
      device_idfa: "192.168.1.106"
    },
    data: JSON.stringify({
      orderId: "ORDER789012",
      status: "PREPARING",
      items: ["汉堡", "薯条", "可乐"]
    })
  },
  {
    log_level: 1,
    // 重要操作信息
    message: "刷卡支付成功",
    time: "2024-02-07 14:18:45",
    device: {
      device_type: "card_reader",
      device_name: "PAX Card Reader",
      device_idfa: "192.168.1.104"
    },
    data: JSON.stringify({
      amount: 58.5,
      cardType: "VISA",
      transactionId: "TXN20240207001",
      status: "SUCCESS"
    })
  },
  {
    log_level: 0,
    // 调试信息
    message: "称重设备校准检查",
    time: "2024-02-07 14:15:30",
    device: {
      device_type: "scale",
      device_name: "Electronic Scale",
      device_idfa: "192.168.1.105"
    },
    data: JSON.stringify({
      calibrationValue: 1e3,
      actualValue: 999.8,
      deviation: 0.2,
      status: "WITHIN_TOLERANCE"
    })
  },
  {
    log_level: 1,
    // 重要操作信息
    message: "钱箱开启",
    time: "2024-02-07 14:12:20",
    device: {
      device_type: "till",
      device_name: "Cash Drawer",
      device_idfa: "192.168.1.107"
    },
    data: JSON.stringify({
      reason: "CASH_PAYMENT",
      orderId: "ORDER345678",
      amount: 25,
      operator: "CASHIER_001"
    })
  },
  {
    log_level: 1,
    // 重要操作信息
    message: "系统启动完成",
    time: "2024-02-07 14:00:00",
    device: {
      device_type: "display",
      device_name: "Samsung Display",
      device_idfa: "192.168.1.103"
    },
    data: JSON.stringify({
      startupTime: "15.234s",
      loadedModules: ["PrinterService", "BarcodeService", "DisplayService"],
      systemStatus: "READY"
    })
  }
];
var HardwareErrorTipDemo = (props) => {
  const [activeTab, setActiveTab] = import_react.default.useState("errors");
  const [loadedErrors, setLoadedErrors] = import_react.default.useState([]);
  const [loadedLogs, setLoadedLogs] = import_react.default.useState([]);
  const [isLoadingErrors, setIsLoadingErrors] = import_react.default.useState(false);
  const [isLoadingLogs, setIsLoadingLogs] = import_react.default.useState(false);
  const loadErrors = import_react.default.useCallback(async () => {
    if (loadedErrors.length > 0) return;
    setIsLoadingErrors(true);
    await new Promise((resolve) => setTimeout(resolve, 1e3));
    setLoadedErrors(mockErrors);
    setIsLoadingErrors(false);
    console.log("错误数据已加载");
  }, [loadedErrors.length]);
  const loadLogs = import_react.default.useCallback(async () => {
    if (loadedLogs.length > 0) return;
    setIsLoadingLogs(true);
    await new Promise((resolve) => setTimeout(resolve, 1500));
    setLoadedLogs(mockLogs);
    setIsLoadingLogs(false);
    console.log("日志数据已加载");
  }, [loadedLogs.length]);
  const handleTabChange = import_react.default.useCallback((newTab) => {
    setActiveTab(newTab);
    if (newTab === "errors") {
      loadErrors();
    } else if (newTab === "logs") {
      loadLogs();
    }
  }, [loadErrors, loadLogs]);
  import_react.default.useEffect(() => {
    loadErrors();
  }, [loadErrors]);
  const handleExportLogs = () => {
    console.log("导出日志功能被调用");
    alert("日志导出功能演示 - 实际项目中这里会下载日志文件");
  };
  const handleCloseError = (errorId) => {
    console.log("关闭错误:", errorId);
    alert(`关闭错误: ${errorId}`);
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { style: { background: "#f0f2f5", height: "100vh", overflow: "hidden" } }, /* @__PURE__ */ import_react.default.createElement(
    import_index.default,
    {
      statistics: mockStatistics,
      errors: loadedErrors,
      logs: loadedLogs,
      activeTab,
      onTabChange: handleTabChange,
      isLoadingErrors,
      isLoadingLogs,
      onExportLogs: handleExportLogs,
      onCloseError: handleCloseError,
      style: props.style
    }
  ), (isLoadingErrors || isLoadingLogs) && /* @__PURE__ */ import_react.default.createElement("div", { style: {
    position: "fixed",
    top: "20px",
    right: "20px",
    background: "#1890ff",
    color: "white",
    padding: "8px 16px",
    borderRadius: "4px",
    fontSize: "12px"
  } }, isLoadingErrors ? "正在加载错误数据..." : "正在加载日志数据..."));
};
var demo_default = HardwareErrorTipDemo;
