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/logCard/index.tsx
var logCard_exports = {};
__export(logCard_exports, {
  default: () => logCard_default
});
module.exports = __toCommonJS(logCard_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_types = require("../types");
var import_locales = require("../../../locales");
var import_index = require("./index.less");
var LOG_LEVEL_MAP = {
  0: "debug",
  // 调试信息
  1: "info",
  // 重要操作信息
  2: "error"
  // 错误信息
};
var LOG_LEVEL_COLORS = {
  debug: "#666",
  info: "#1890ff",
  error: "#ff4d4f"
};
var DEVICE_TYPE_MAP = {
  printer: (0, import_locales.getText)("pisell2.text.hardware-error.device.printer"),
  barcode_scanner: (0, import_locales.getText)("pisell2.text.hardware-error.device.barcode-scanner"),
  cds: (0, import_locales.getText)("pisell2.text.hardware-error.device.cds"),
  kds: (0, import_locales.getText)("pisell2.text.hardware-error.device.kds"),
  display: (0, import_locales.getText)("pisell2.text.hardware-error.device.display"),
  card_reader: (0, import_locales.getText)("pisell2.text.hardware-error.device.card-reader"),
  till: (0, import_locales.getText)("pisell2.text.hardware-error.device.till"),
  scale: (0, import_locales.getText)("pisell2.text.hardware-error.device.scale")
};
var LogCard = (props) => {
  const { data } = props;
  const logLevel = LOG_LEVEL_MAP[data.log_level];
  const logLevelColor = LOG_LEVEL_COLORS[logLevel];
  const deviceTypeName = DEVICE_TYPE_MAP[data.device.device_type] || data.device.device_type;
  const formatTime = (timeStr) => {
    try {
      const date = new Date(timeStr);
      return date.toLocaleString("zh-CN", {
        year: "numeric",
        month: "2-digit",
        day: "2-digit",
        hour: "2-digit",
        minute: "2-digit",
        second: "2-digit",
        fractionalSecondDigits: 3
      });
    } catch {
      return timeStr;
    }
  };
  const formatLogLevel = (level) => {
    const levelMap = {
      0: "DEBUG",
      1: "INFO",
      2: "ERROR"
    };
    return levelMap[level];
  };
  const formatData = (dataStr) => {
    if (!dataStr) return null;
    try {
      const parsed = JSON.parse(dataStr);
      return JSON.stringify(parsed, null, 2);
    } catch {
      return dataStr;
    }
  };
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(`${import_types.prefix}-log-card`, logLevel),
      style: {
        borderLeftColor: logLevelColor
      }
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-log-card-header` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-log-card-time` }, formatTime(data.time)), /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: `${import_types.prefix}-log-card-level`,
        style: { color: logLevelColor }
      },
      formatLogLevel(data.log_level)
    ), /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-log-card-device-id` }, data.device.device_idfa)),
    /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-log-card-content` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-log-card-service` }, "[", deviceTypeName, "] ", data.message), data.data && /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-log-card-data` }, /* @__PURE__ */ import_react.default.createElement("pre", null, formatData(data.data))))
  );
};
var logCard_default = LogCard;
