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/errorCard/index.tsx
var errorCard_exports = {};
__export(errorCard_exports, {
  default: () => errorCard_default
});
module.exports = __toCommonJS(errorCard_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_icons = require("@ant-design/icons");
var import_iconfont = __toESM(require("../../iconfont"));
var import_types = require("../types");
var import_locales = require("../../../locales");
var import_index = require("./index.less");
var ERROR_LEVEL_MAP = {
  0: "fatal",
  // 致命错误
  1: "critical",
  // 严重错误
  2: "normal",
  // 一般错误
  3: "info"
  // 提示信息
};
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 DEVICE_ICON_MAP = {
  printer: "pisell2-printer",
  barcode_scanner: "pisell2-a-Scanner1",
  cds: "pisell2-a-device1",
  kds: "pisell2-a-device1",
  display: "pisell2-monitor-03",
  card_reader: "pisell2-a-NFC2",
  till: "pisell2-coins-hand",
  scale: "pisell2-scales-02"
};
var ErrorCard = (props) => {
  const { data, onClose } = props;
  const errorType = ERROR_LEVEL_MAP[data.error_level];
  const errorConfig = import_types.errorTypes.find((type) => type.type === errorType);
  const theme = import_types.ErrorTypeTheme[errorType];
  const deviceTypeName = DEVICE_TYPE_MAP[data.device.device_type] || data.device.device_type;
  const deviceIcon = DEVICE_ICON_MAP[data.device.device_type] || "pisell2-container";
  if (!errorConfig) {
    return null;
  }
  const IconComponent = errorConfig.icon;
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(`${import_types.prefix}-error-card`, errorType),
      style: {
        backgroundColor: theme.backgroundColor,
        borderLeft: `4px solid ${theme.iconColor}`
      }
    },
    onClose && !["fatal", "critical"].includes(errorType) && /* @__PURE__ */ import_react.default.createElement(
      import_icons.CloseCircleOutlined,
      {
        className: `${import_types.prefix}-error-card-close`,
        onClick: onClose
      }
    ),
    /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-header` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-level` }, /* @__PURE__ */ import_react.default.createElement(
      "span",
      {
        className: `${import_types.prefix}-error-card-level-text`,
        style: {
          color: theme.iconColor,
          backgroundColor: theme.badgeColor
        }
      },
      errorConfig.title()
    ), /* @__PURE__ */ import_react.default.createElement("span", { className: `${import_types.prefix}-error-card-device` }, /* @__PURE__ */ import_react.default.createElement(import_iconfont.default, { type: deviceIcon, style: { marginRight: 8, fontSize: 16 } }), deviceTypeName))),
    /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-content` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-info-row` }, /* @__PURE__ */ import_react.default.createElement("span", { className: `${import_types.prefix}-error-card-label` }, (0, import_locales.getText)("pisell2.text.hardware-error.error-code"), ":"), /* @__PURE__ */ import_react.default.createElement("span", { className: `${import_types.prefix}-error-card-value` }, data.error_code), /* @__PURE__ */ import_react.default.createElement("span", { className: `${import_types.prefix}-error-card-label` }, (0, import_locales.getText)("pisell2.text.hardware-error.time"), ":"), /* @__PURE__ */ import_react.default.createElement("span", { className: `${import_types.prefix}-error-card-value` }, data.time)), /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-description` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-label` }, (0, import_locales.getText)("pisell2.text.hardware-error.error-description"), ":"), /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-message` }, data.error_message)), /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-solution` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-label` }, (0, import_locales.getText)("pisell2.text.hardware-error.solution"), ":"), /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_types.prefix}-error-card-solution-text` }, "请检查", deviceTypeName, "电源和连接线")))
  );
};
var errorCard_default = ErrorCard;
