import { getText } from "../../../locales/index.js";
import IconFont from "../../iconfont/index.js";
import { ErrorTypeTheme, errorTypes, prefix } from "../types.js";
import React from "react";
import { CloseCircleOutlined } from "@ant-design/icons";
import classNames from "classnames";
import "./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: getText("pisell2.text.hardware-error.device.printer"),
	barcode_scanner: getText("pisell2.text.hardware-error.device.barcode-scanner"),
	cds: getText("pisell2.text.hardware-error.device.cds"),
	kds: getText("pisell2.text.hardware-error.device.kds"),
	display: getText("pisell2.text.hardware-error.device.display"),
	card_reader: getText("pisell2.text.hardware-error.device.card-reader"),
	till: getText("pisell2.text.hardware-error.device.till"),
	scale: 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 = errorTypes.find((type) => type.type === errorType);
	const theme = 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.createElement("div", {
		className: classNames(`${prefix}-error-card`, errorType),
		style: {
			backgroundColor: theme.backgroundColor,
			borderLeft: `4px solid ${theme.iconColor}`
		}
	}, onClose && !["fatal", "critical"].includes(errorType) && /* @__PURE__ */ React.createElement(CloseCircleOutlined, {
		className: `pisell-lowcode-error-card-close`,
		onClick: onClose
	}), /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-header` }, /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-level` }, /* @__PURE__ */ React.createElement("span", {
		className: `${prefix}-error-card-level-text`,
		style: {
			color: theme.iconColor,
			backgroundColor: theme.badgeColor
		}
	}, errorConfig.title()), /* @__PURE__ */ React.createElement("span", { className: `${prefix}-error-card-device` }, /* @__PURE__ */ React.createElement(IconFont, {
		type: deviceIcon,
		style: {
			marginRight: 8,
			fontSize: 16
		}
	}), deviceTypeName))), /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-content` }, /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-info-row` }, /* @__PURE__ */ React.createElement("span", { className: `${prefix}-error-card-label` }, getText("pisell2.text.hardware-error.error-code"), ":"), /* @__PURE__ */ React.createElement("span", { className: `${prefix}-error-card-value` }, data.error_code), /* @__PURE__ */ React.createElement("span", { className: `${prefix}-error-card-label` }, getText("pisell2.text.hardware-error.time"), ":"), /* @__PURE__ */ React.createElement("span", { className: `${prefix}-error-card-value` }, data.time)), /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-description` }, /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-label` }, getText("pisell2.text.hardware-error.error-description"), ":"), /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-message` }, data.error_message)), /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-solution` }, /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-label` }, getText("pisell2.text.hardware-error.solution"), ":"), /* @__PURE__ */ React.createElement("div", { className: `${prefix}-error-card-solution-text` }, "请检查", deviceTypeName, "电源和连接线"))));
};
//#endregion
export { ErrorCard as default };
