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/plus/saasDevice/deviceProfile/components/DeleteProfileModal/index.tsx
var DeleteProfileModal_exports = {};
__export(DeleteProfileModal_exports, {
  default: () => DeleteProfileModal_default
});
module.exports = __toCommonJS(DeleteProfileModal_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_icons = require("@ant-design/icons");
var import_index = require("./index.less");
var DeleteProfileModal = ({
  open,
  loading,
  submitting,
  profileName,
  linkedDevices,
  translation,
  getText,
  onClose,
  onConfirm
}) => {
  const hasLinked = linkedDevices.length > 0;
  const renderConfirmBody = () => {
    const tpl = getText("pisell2.saas.device-profile.delete.confirm.content");
    const [before, after] = tpl.split("{ProfileName}");
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__body" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__confirm-text" }, before, /* @__PURE__ */ import_react.default.createElement("strong", null, profileName), after));
  };
  const renderLinkedBody = () => {
    const tpl = getText("pisell2.saas.device-profile.delete.linked.content");
    const text = tpl.replace("{ProfileName}", "__PROFILE__").replace("{N}", String(linkedDevices.length));
    const [before, after] = text.split("__PROFILE__");
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__body" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__warning" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__warning-title" }, /* @__PURE__ */ import_react.default.createElement(import_icons.ExclamationCircleFilled, { className: "delete-profile-modal__warning-icon" }), getText("pisell2.saas.device-profile.delete.linked.title")), /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__warning-content" }, before, /* @__PURE__ */ import_react.default.createElement("strong", null, profileName), after)), /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__devices-label" }, getText("pisell2.saas.device-profile.delete.linked.devicesLabel")), /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__devices-list" }, linkedDevices.map((d) => {
      var _a, _b;
      return /* @__PURE__ */ import_react.default.createElement("div", { key: d.id, className: "delete-profile-modal__device-row" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__device-name" }, /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "DesktopOutlined" }), /* @__PURE__ */ import_react.default.createElement("span", null, translation(d.name))), d.workarea ? /* @__PURE__ */ import_react.default.createElement(import_antd.Tag, { key: (_a = d == null ? void 0 : d.workarea) == null ? void 0 : _a.id }, translation((_b = d.workarea) == null ? void 0 : _b.name)) : null);
    })));
  };
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      open,
      onCancel: onClose,
      headerDivider: false,
      footerDivider: false,
      title: getText("pisell2.saas.device-profile.delete.title"),
      okVisible: !hasLinked,
      cancelButtonProps: {
        disabled: submitting
      },
      okButtonProps: {
        danger: true,
        loading: submitting,
        onClick: onConfirm
      },
      cancelText: getText(
        hasLinked ? "pisell2.saas.device-profile.delete.button.close" : "pisell2.saas.device-profile.delete.button.cancel"
      ),
      okText: getText("pisell2.saas.device-profile.delete.button.delete"),
      closable: true,
      width: 520,
      destroyOnClose: true,
      maskClosable: false,
      className: "delete-profile-modal"
    },
    /* @__PURE__ */ import_react.default.createElement("div", null, loading ? /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-profile-modal__loading" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, null)) : hasLinked ? renderLinkedBody() : renderConfirmBody())
  );
};
var DeleteProfileModal_default = DeleteProfileModal;
