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/camera/index.ts var camera_exports = {}; __export(camera_exports, { deviceIDToDeviceKey: () => deviceIDToDeviceKey, deviceKeyToDeviceId: () => deviceKeyToDeviceId, deviceToDeviceKey: () => deviceToDeviceKey, findCamerasByInDeviceTree: () => findCamerasByInDeviceTree, getDeviceType: () => getDeviceType, getVmsIdByDeviceId: () => getVmsIdByDeviceId, isFaceCamera: () => isFaceCamera }); module.exports = __toCommonJS(camera_exports); var import_lodash_es = require("lodash-es"); var import_utils = require("../utils"); var import_constants = require("./constants"); var isFaceCamera = (type) => { return [ import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_1400, import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_HKGRABBER, import_constants.DevicemanagerCameraType.DEVICEMANAGER_CAMERA_TYPE_DHGRABBER ].includes(type); }; function getDeviceType(value) { let type; let isDeviceKey = (0, import_lodash_es.isString)(value); if (isDeviceKey) { type = value.split("_")[0]; } else { if ((0, import_lodash_es.has)(value, "longitude")) { type = import_constants.DeviceType["CAMERA"]; } if ((0, import_lodash_es.has)(value, "ip")) { type = import_constants.DeviceType["VMS"]; } if (!type) { type = import_constants.DeviceType["DIR"]; } } return type; } function deviceIDToDeviceKey(id, type, vmsId) { if (type == import_constants.DeviceType["DIR"]) { return `${type}_${id}_${vmsId}`; } else { return `${type}_${id}`; } } function deviceToDeviceKey(item) { let deviceKey = ""; let type = getDeviceType(item); if (!type) { console.error("device type is null!"); } switch (type) { case import_constants.DeviceType["DIR"]: { let dirId = item["dirid"] || item["dirId"]; if (!dirId && dirId !== 0) { console.error("dirId type is null!"); } let vmsId = (0, import_lodash_es.get)(item, "extendInfo.vmsPlatformId"); if (!vmsId && vmsId !== 0) { console.error("vmsId type is null!"); } deviceKey = `${type}_${dirId}_${vmsId}`; } break; case import_constants.DeviceType["VMS"]: deviceKey = `${type}_${item["id"]}`; break; case import_constants.DeviceType["CAMERA"]: { let vmsId = (0, import_lodash_es.get)(item, "extendInfo.vmsPlatformId"); if (!vmsId && vmsId !== 0) { console.error("vmsId type is null!"); } deviceKey = `${type}_${item.id}`; } break; } return deviceKey; } function deviceKeyToDeviceId(deviceKey) { let [type, id] = deviceKey.split("_"); return type === import_constants.DeviceType["DIR"] ? id : Number(id); } var getVmsIdByDeviceId = (key) => { const type = getDeviceType(key); let vmsId = ""; switch (type) { case import_constants.DeviceType["CAMERA"]: case import_constants.DeviceType["DIR"]: vmsId = key.split("_")[2]; break; case import_constants.DeviceType["VMS"]: vmsId = key.split("_")[1]; break; } if (!vmsId) { console.error("vmsid is null!"); } return vmsId; }; var findCamerasByInDeviceTree = (ids = [], deviceTree, type = "id") => { let cameraInfoList = []; let _ids = ids.map((v) => String(v)); (0, import_utils.loop)(deviceTree, (item) => { let isCamera = getDeviceType((0, import_lodash_es.get)(item, "key", "")) === import_constants.DeviceType["CAMERA"]; let isMatch = type === "key" ? _ids.includes((0, import_lodash_es.get)(item, "key")) : _ids.includes(`${(0, import_lodash_es.get)(item, "origin.id")}`); if (isCamera && isMatch) { cameraInfoList.push(item); } }); return cameraInfoList; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { deviceIDToDeviceKey, deviceKeyToDeviceId, deviceToDeviceKey, findCamerasByInDeviceTree, getDeviceType, getVmsIdByDeviceId, isFaceCamera });