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/devicePlanning/components/shared/DeviceBasicInfoForm.tsx
var DeviceBasicInfoForm_exports = {};
__export(DeviceBasicInfoForm_exports, {
  default: () => DeviceBasicInfoForm_default
});
module.exports = __toCommonJS(DeviceBasicInfoForm_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_model = require("../../model");
var DeviceBasicInfoForm = ({
  form,
  selectedModel,
  profiles = [],
  profileRequired,
  showProfile,
  showShortNumber,
  workAreas,
  workAreaId,
  currentWorkAreaId,
  getText,
  translation,
  onWorkAreaChange,
  onValuesChange,
  showSelectedModel = true
}) => {
  var _a;
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "add-device-modal__body", style: { minHeight: "auto" } }, showSelectedModel && selectedModel ? /* @__PURE__ */ import_react.default.createElement("div", { className: "add-device-modal__selected-model" }, /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: ((_a = selectedModel.type) == null ? void 0 : _a.icon) || "DesktopOutlined" }), /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { className: "add-device-modal__model-name" }, translation(selectedModel.name) || ""), /* @__PURE__ */ import_react.default.createElement("div", { className: "add-device-modal__model-desc" }, translation(selectedModel.description) || ""))) : null, /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form,
    {
      form,
      layout: "vertical",
      preserve: false,
      onValuesChange
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        name: "name",
        label: getText("pisell2.saas.device-planning.add.device-name"),
        required: true,
        rules: [
          {
            validator: (0, import_model.validateI18nRequired)(
              getText("pisell2.saas.device-planning.add.device-name-required")
            )
          }
        ]
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_materials.BaseTranslation,
        {
          renderMode: "edit",
          placeholder: getText(
            "pisell2.saas.device-planning.add.device-name-placeholder"
          )
        }
      )
    ),
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        name: "description",
        label: getText("pisell2.saas.device-planning.modal.description")
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_materials.BaseTranslation,
        {
          renderMode: "edit",
          type: "textarea",
          placeholder: getText(
            "pisell2.saas.device-planning.modal.description-placeholder"
          )
        }
      )
    ),
    showShortNumber ? /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        name: "short_number",
        label: getText(
          "pisell2.saas.device-planning.device-short-number.label"
        ),
        normalize: (value) => (0, import_model.normalizeDeviceShortNumberInput)(value),
        required: true,
        rules: [
          {
            validator: (0, import_model.validateDeviceShortNumber)({
              required: getText(
                "pisell2.saas.device-planning.device-short-number.required"
              ),
              format: getText(
                "pisell2.saas.device-planning.device-short-number.format"
              ),
              reserved: getText(
                "pisell2.saas.device-planning.device-short-number.reserved"
              )
            })
          }
        ],
        extra: getText(
          "pisell2.saas.device-planning.device-short-number.helper"
        )
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_antd.Input,
        {
          maxLength: import_model.DEVICE_SHORT_NUMBER_MAX_LENGTH,
          placeholder: getText(
            "pisell2.saas.device-planning.device-short-number.placeholder"
          )
        }
      )
    ) : null,
    workAreas ? /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        label: getText("pisell2.saas.device-planning.edit.work-area"),
        required: true
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_antd.Select,
        {
          value: workAreaId,
          placeholder: getText(
            "pisell2.saas.device-planning.edit.work-area-placeholder"
          ),
          options: workAreas.map((area) => ({
            label: `${translation(area.name) || area.id}${area.id === currentWorkAreaId ? ` (${getText(
              "pisell2.saas.device-planning.connect.current"
            )})` : ""}`,
            value: area.id
          })),
          onChange: (value) => onWorkAreaChange == null ? void 0 : onWorkAreaChange(value)
        }
      )
    ) : null,
    showProfile && profileRequired ? /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        name: "profile_id",
        label: getText("pisell2.saas.device-planning.add.device-profile"),
        required: true,
        rules: [
          {
            required: true,
            message: getText(
              "pisell2.saas.device-planning.add.device-profile-required"
            )
          }
        ],
        help: profiles.length === 0 ? getText("pisell2.saas.device-planning.add.create-profile-first") : void 0
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_antd.Select,
        {
          disabled: profiles.length === 0,
          placeholder: getText(
            "pisell2.saas.device-planning.add.device-profile-placeholder"
          ),
          options: profiles.map((profile) => ({
            label: translation(profile.name) || String(profile.id),
            value: profile.id
          })),
          allowClear: true
        }
      )
    ) : null
  ));
};
var DeviceBasicInfoForm_default = DeviceBasicInfoForm;
