"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 GetPriorityRouteMessages_exports = {};
__export(GetPriorityRouteMessages_exports, {
  GetPriorityRouteRequest: () => GetPriorityRouteRequest,
  GetPriorityRouteResponse: () => GetPriorityRouteResponse
});
module.exports = __toCommonJS(GetPriorityRouteMessages_exports);
var import_tslib = require("tslib");
var import_core = require("@zwave-js/core");
var import_serial = require("@zwave-js/serial");
var import_shared = require("@zwave-js/shared");
let GetPriorityRouteRequest = (() => {
  let _classDecorators = [(0, import_serial.messageTypes)(import_serial.MessageType.Request, import_serial.FunctionType.GetPriorityRoute), (0, import_serial.priority)(import_core.MessagePriority.Normal), (0, import_serial.expectedResponse)(import_serial.FunctionType.GetPriorityRoute)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_serial.Message;
  var GetPriorityRouteRequest2 = class extends _classSuper {
    static {
      __name(this, "GetPriorityRouteRequest");
    }
    static {
      _classThis = this;
    }
    static {
      const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
      (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
      GetPriorityRouteRequest2 = _classThis = _classDescriptor.value;
      if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
      (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
    }
    constructor(options) {
      super(options);
      this.destinationNodeId = options.destinationNodeId;
    }
    static from(_raw, _ctx) {
      throw new import_core.ZWaveError(`${this.name}: deserialization not implemented`, import_core.ZWaveErrorCodes.Deserialization_NotImplemented);
    }
    destinationNodeId;
    serialize(ctx) {
      this.payload = (0, import_core.encodeNodeID)(this.destinationNodeId, ctx.nodeIdType);
      return super.serialize(ctx);
    }
    toLogEntry() {
      return {
        ...super.toLogEntry(),
        message: {
          "node ID": this.destinationNodeId
        }
      };
    }
  };
  return GetPriorityRouteRequest2 = _classThis;
})();
let GetPriorityRouteResponse = (() => {
  let _classDecorators = [(0, import_serial.messageTypes)(import_serial.MessageType.Response, import_serial.FunctionType.GetPriorityRoute)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_serial.Message;
  var GetPriorityRouteResponse2 = class extends _classSuper {
    static {
      __name(this, "GetPriorityRouteResponse");
    }
    static {
      _classThis = this;
    }
    static {
      const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
      (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
      GetPriorityRouteResponse2 = _classThis = _classDescriptor.value;
      if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
      (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
    }
    constructor(options) {
      super(options);
      this.destinationNodeId = options.destinationNodeId;
      this.routeKind = options.routeKind;
      this.repeaters = options.repeaters;
      this.routeSpeed = options.routeSpeed;
    }
    static from(raw, ctx) {
      let offset = 0;
      const { nodeId, bytesRead: nodeIdBytes } = (0, import_core.parseNodeID)(raw.payload, ctx.nodeIdType, offset);
      offset += nodeIdBytes;
      const destinationNodeId = nodeId;
      const routeKind = raw.payload[offset++];
      let repeaters;
      let routeSpeed;
      if (routeKind) {
        repeaters = [
          ...raw.payload.subarray(offset, offset + import_core.MAX_REPEATERS)
        ].filter((id) => id > 0);
        routeSpeed = raw.payload[offset + import_core.MAX_REPEATERS];
      }
      return new this({
        destinationNodeId,
        routeKind,
        repeaters,
        routeSpeed
      });
    }
    destinationNodeId;
    routeKind;
    repeaters;
    routeSpeed;
    toLogEntry() {
      let message = {
        "node ID": this.destinationNodeId
      };
      if (this.routeKind !== import_core.RouteKind.None) {
        message = {
          ...message,
          "route kind": (0, import_shared.getEnumMemberName)(import_core.RouteKind, this.routeKind),
          repeaters: this.repeaters?.length ? this.repeaters.join(" -> ") : "none",
          "route speed": (0, import_shared.getEnumMemberName)(import_core.ZWaveDataRate, this.routeSpeed)
        };
      } else {
        message = {
          ...message,
          route: "(not set)"
        };
      }
      return {
        ...super.toLogEntry(),
        message
      };
    }
  };
  return GetPriorityRouteResponse2 = _classThis;
})();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  GetPriorityRouteRequest,
  GetPriorityRouteResponse
});
//# sourceMappingURL=GetPriorityRouteMessages.js.map
