const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../locales/index.js");
const require_index$1 = require("../../iconfont/index.js");
const require_types = require("../types.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _ant_design_icons = require("@ant-design/icons");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/hardwareErrorTip/errorCard/index.tsx
const ERROR_LEVEL_MAP = {
	0: "fatal",
	1: "critical",
	2: "normal",
	3: "info"
};
const DEVICE_TYPE_MAP = {
	printer: require_index.getText("pisell2.text.hardware-error.device.printer"),
	barcode_scanner: require_index.getText("pisell2.text.hardware-error.device.barcode-scanner"),
	cds: require_index.getText("pisell2.text.hardware-error.device.cds"),
	kds: require_index.getText("pisell2.text.hardware-error.device.kds"),
	display: require_index.getText("pisell2.text.hardware-error.device.display"),
	card_reader: require_index.getText("pisell2.text.hardware-error.device.card-reader"),
	till: require_index.getText("pisell2.text.hardware-error.device.till"),
	scale: require_index.getText("pisell2.text.hardware-error.device.scale")
};
const 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"
};
const ErrorCard = (props) => {
	const { data, onClose } = props;
	const errorType = ERROR_LEVEL_MAP[data.error_level];
	const errorConfig = require_types.errorTypes.find((type) => type.type === errorType);
	const theme = require_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;
	errorConfig.icon;
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)(`${require_types.prefix}-error-card`, errorType),
		style: {
			backgroundColor: theme.backgroundColor,
			borderLeft: `4px solid ${theme.iconColor}`
		}
	}, onClose && !["fatal", "critical"].includes(errorType) && /* @__PURE__ */ react.default.createElement(_ant_design_icons.CloseCircleOutlined, {
		className: `pisell-lowcode-error-card-close`,
		onClick: onClose
	}), /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-header` }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-level` }, /* @__PURE__ */ react.default.createElement("span", {
		className: `${require_types.prefix}-error-card-level-text`,
		style: {
			color: theme.iconColor,
			backgroundColor: theme.badgeColor
		}
	}, errorConfig.title()), /* @__PURE__ */ react.default.createElement("span", { className: `${require_types.prefix}-error-card-device` }, /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		type: deviceIcon,
		style: {
			marginRight: 8,
			fontSize: 16
		}
	}), deviceTypeName))), /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-content` }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-info-row` }, /* @__PURE__ */ react.default.createElement("span", { className: `${require_types.prefix}-error-card-label` }, require_index.getText("pisell2.text.hardware-error.error-code"), ":"), /* @__PURE__ */ react.default.createElement("span", { className: `${require_types.prefix}-error-card-value` }, data.error_code), /* @__PURE__ */ react.default.createElement("span", { className: `${require_types.prefix}-error-card-label` }, require_index.getText("pisell2.text.hardware-error.time"), ":"), /* @__PURE__ */ react.default.createElement("span", { className: `${require_types.prefix}-error-card-value` }, data.time)), /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-description` }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-label` }, require_index.getText("pisell2.text.hardware-error.error-description"), ":"), /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-message` }, data.error_message)), /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-solution` }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-label` }, require_index.getText("pisell2.text.hardware-error.solution"), ":"), /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-error-card-solution-text` }, "请检查", deviceTypeName, "电源和连接线"))));
};
//#endregion
exports.default = ErrorCard;
