"use strict";
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);
var NodeNamingAndLocation_exports = {};
__export(NodeNamingAndLocation_exports, {
  NodeNamingAndLocationCCBehaviors: () => NodeNamingAndLocationCCBehaviors
});
module.exports = __toCommonJS(NodeNamingAndLocation_exports);
var import_NodeNamingCC = require("@zwave-js/cc/NodeNamingCC");
var import_core = require("@zwave-js/core");
const defaultCapabilities = {};
const STATE_KEY_PREFIX = "NodeNamingAndLocation_";
const StateKeys = {
  name: `${STATE_KEY_PREFIX}name`,
  location: `${STATE_KEY_PREFIX}location`
};
const respondToNodeNameGet = {
  handleCC(controller, self, receivedCC) {
    if (receivedCC instanceof import_NodeNamingCC.NodeNamingAndLocationCCNameGet) {
      const capabilities = self.getCCCapabilities(import_core.CommandClasses["Node Naming and Location"], 0) ?? defaultCapabilities;
      const cc = new import_NodeNamingCC.NodeNamingAndLocationCCNameReport({
        nodeId: controller.ownNodeId,
        name: self.state.get(StateKeys.name) ?? capabilities.name ?? ""
      });
      return { action: "sendCC", cc };
    }
  }
};
const respondToNodeNameSet = {
  handleCC(controller, self, receivedCC) {
    if (receivedCC instanceof import_NodeNamingCC.NodeNamingAndLocationCCNameSet) {
      self.state.set(StateKeys.name, receivedCC.name);
      return { action: "ok" };
    }
  }
};
const respondToNodeLocationGet = {
  handleCC(controller, self, receivedCC) {
    if (receivedCC instanceof import_NodeNamingCC.NodeNamingAndLocationCCLocationGet) {
      const capabilities = self.getCCCapabilities(import_core.CommandClasses["Node Naming and Location"], 0) ?? defaultCapabilities;
      const cc = new import_NodeNamingCC.NodeNamingAndLocationCCLocationReport({
        nodeId: controller.ownNodeId,
        location: self.state.get(StateKeys.location) ?? capabilities.location ?? ""
      });
      return { action: "sendCC", cc };
    }
  }
};
const respondToNodeLocationSet = {
  handleCC(controller, self, receivedCC) {
    if (receivedCC instanceof import_NodeNamingCC.NodeNamingAndLocationCCLocationSet) {
      self.state.set(StateKeys.location, receivedCC.location);
      return { action: "ok" };
    }
  }
};
const NodeNamingAndLocationCCBehaviors = [
  respondToNodeNameGet,
  respondToNodeNameSet,
  respondToNodeLocationGet,
  respondToNodeLocationSet
];
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  NodeNamingAndLocationCCBehaviors
});
//# sourceMappingURL=NodeNamingAndLocation.js.map
