const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_materials = require("@pisell/materials");
let _ant_design_icons = require("@ant-design/icons");
//#region src/plus/saasDevice/appPeripheral/components/PeripheralConnectionCard.tsx
const PeripheralConnectionCard = ({ model, getText, onEdit, onRemove, onRequestDisconnect, onOpenUsageSelect, onTest, onOpenPhysicalSelect, onConnect }) => {
	const renderStatusTag = () => {
		const color = model.status === "connected" ? "green" : model.status === "connecting" ? "gold" : "red";
		return /* @__PURE__ */ react.default.createElement(_pisell_materials.Tag, { color }, getText(`pisell2.saas.app-peripheral.status.${model.status}`));
	};
	const getActionItems = () => [
		{
			key: "edit",
			icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.EditOutlined, null),
			label: getText("pisell2.saas.app-peripheral.edit"),
			onClick: () => onEdit(model.connection)
		},
		...model.canDisconnect ? [{
			key: "disconnect",
			icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.DisconnectOutlined, null),
			label: getText("pisell2.saas.app-peripheral.disconnect"),
			onClick: () => onRequestDisconnect(model.connection)
		}] : [],
		{
			key: "remove",
			icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.DeleteOutlined, null),
			danger: true,
			label: getText("pisell2.saas.app-peripheral.remove"),
			onClick: () => onRemove(model.connection)
		}
	];
	return /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__card" }, /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__card-icon" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, { type: model.icon })), /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__card-main" }, /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__card-title-row" }, /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__card-title" }, model.title), renderStatusTag()), /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__card-subtitle" }, model.subtitle), /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__meta" }, /* @__PURE__ */ react.default.createElement("span", null, getText("pisell2.saas.app-peripheral.model"), ":\xA0", model.modelName), /* @__PURE__ */ react.default.createElement("span", { className: "saas-app-peripheral__tag" }, model.connectionTypeLabel), model.connectionDetail ? /* @__PURE__ */ react.default.createElement("span", { className: "saas-app-peripheral__tag" }, model.connectionDetail) : null), model.profileLabels.length ? /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__meta" }, /* @__PURE__ */ react.default.createElement("span", null, getText("pisell2.saas.app-peripheral.profiles"), ":"), model.profileLabels.map((label) => /* @__PURE__ */ react.default.createElement("span", {
		key: String(label),
		className: "saas-app-peripheral__tag"
	}, label))) : null), /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-peripheral__card-actions" }, model.canTest ? /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.PlayCircleOutlined, null),
		onClick: onTest
	}, getText("pisell2.saas.app-peripheral.test")) : model.canConnect ? /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		type: "primary",
		icon: /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, { type: "ApiOutlined" }),
		disabled: model.actionDisabled,
		onClick: () => {
			if (model.isUsageAction) {
				onOpenUsageSelect();
				return;
			}
			if (model.isSelectAction) {
				onOpenPhysicalSelect();
				return;
			}
			onConnect();
		}
	}, model.actionText) : null, /* @__PURE__ */ react.default.createElement(antd.Dropdown, {
		menu: { items: getActionItems() },
		trigger: ["click"],
		placement: "bottomRight"
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		type: "text",
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.MoreOutlined, null)
	}))));
};
//#endregion
exports.default = PeripheralConnectionCard;
