var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/saasDevice/devicePlanning/model/adapters.ts
var adapters_exports = {};
__export(adapters_exports, {
  createDeviceRow: () => createDeviceRow,
  flattenDeviceModels: () => flattenDeviceModels,
  getDeleteWorkAreaCounts: () => getDeleteWorkAreaCounts,
  resolveWorkAreaDetail: () => resolveWorkAreaDetail
});
module.exports = __toCommonJS(adapters_exports);
var flattenDeviceModels = (types) => {
  const modelMap = /* @__PURE__ */ new Map();
  types.forEach((type) => {
    (type.active_models || []).forEach((model) => {
      if (!modelMap.has(model.code)) {
        modelMap.set(model.code, { ...model, type: model.type || type });
      }
    });
  });
  return Array.from(modelMap.values());
};
var createDeviceRow = (item, translation, profileNameMap) => {
  var _a, _b, _c;
  const name = translation(item.name);
  const typeName = translation((_a = item.type) == null ? void 0 : _a.name) || item.type_code;
  const modelName = translation((_b = item.model) == null ? void 0 : _b.name) || item.model_code;
  const link = item.link || "unlinked";
  const profileName = translation((_c = item.profile) == null ? void 0 : _c.name) || (item.profile_id ? profileNameMap == null ? void 0 : profileNameMap.get(item.profile_id) : "") || (item.profile_id ? String(item.profile_id) : "-");
  return {
    id: item.id,
    name,
    typeName,
    modelName,
    profileName,
    link,
    status: item.type_kind === "dumb" ? item.status || "unknown" : link === "linked" ? item.status || "offline" : "unknown",
    structure: item.structure,
    typeCode: item.type_code,
    modelCode: item.model_code,
    _raw: item
  };
};
var resolveWorkAreaDetail = (response) => {
  const data = response == null ? void 0 : response.data;
  if (Array.isArray(data)) return data[0];
  return data || response;
};
var getDeleteWorkAreaCounts = (response) => {
  const workArea = resolveWorkAreaDetail(response);
  return {
    smart: (workArea == null ? void 0 : workArea.smart_devices_count) || 0,
    dumb: (workArea == null ? void 0 : workArea.dumb_devices_count) || 0,
    integrated: (workArea == null ? void 0 : workArea.integrated_devices_count) || 0
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  createDeviceRow,
  flattenDeviceModels,
  getDeleteWorkAreaCounts,
  resolveWorkAreaDetail
});
