"use strict";
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 __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 __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);
var SceneActivationCC_exports = {};
__export(SceneActivationCC_exports, {
  SceneActivationCC: () => SceneActivationCC,
  SceneActivationCCAPI: () => SceneActivationCCAPI,
  SceneActivationCCSet: () => SceneActivationCCSet,
  SceneActivationCCValues: () => import_CCValues_generated.SceneActivationCCValues
});
module.exports = __toCommonJS(SceneActivationCC_exports);
var import_tslib = require("tslib");
var __validateArgs = __toESM(require("./SceneActivationCC._validateArgs.js"), 1);
var import_core = require("@zwave-js/core");
var import_shared = require("@zwave-js/shared");
var import_API = require("../lib/API.js");
var import_CommandClass = require("../lib/CommandClass.js");
var import_CommandClassDecorators = require("../lib/CommandClassDecorators.js");
var import_Types = require("../lib/_Types.js");
var import_CCValues_generated = require("./_CCValues.generated.js");
const { validateArgs_SceneActivationCCAPI_set } = __validateArgs;
let SceneActivationCCAPI = (() => {
  let _classDecorators = [(0, import_CommandClassDecorators.API)(import_core.CommandClasses["Scene Activation"])];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_API.CCAPI;
  let _instanceExtraInitializers = [];
  let _set_decorators;
  var SceneActivationCCAPI2 = class extends _classSuper {
    static {
      __name(this, "SceneActivationCCAPI");
    }
    static {
      _classThis = this;
    }
    static {
      const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
      _set_decorators = [validateArgs_SceneActivationCCAPI_set()];
      (0, import_tslib.__esDecorate)(this, null, _set_decorators, { kind: "method", name: "set", static: false, private: false, access: { has: /* @__PURE__ */ __name((obj) => "set" in obj, "has"), get: /* @__PURE__ */ __name((obj) => obj.set, "get") }, metadata: _metadata }, null, _instanceExtraInitializers);
      (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
      SceneActivationCCAPI2 = _classThis = _classDescriptor.value;
      if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
      (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
    }
    supportsCommand(_cmd) {
      return true;
    }
    get [import_API.SET_VALUE]() {
      return async function({ property }, value, options) {
        if (property !== "sceneId") {
          (0, import_API.throwUnsupportedProperty)(this.ccId, property);
        }
        if (typeof value !== "number") {
          (0, import_API.throwWrongValueType)(this.ccId, property, "number", typeof value);
        }
        const duration = import_core.Duration.from(options?.transitionDuration);
        return this.set(value, duration);
      };
    }
    /**
     * Activates the Scene with the given ID
     * @param duration The duration specifying how long the transition should take. Can be a Duration instance or a user-friendly duration string like `"1m17s"`.
     */
    async set(sceneId, dimmingDuration) {
      this.assertSupportsCommand(import_Types.SceneActivationCommand, import_Types.SceneActivationCommand.Set);
      const cc = new SceneActivationCCSet({
        nodeId: this.endpoint.nodeId,
        endpointIndex: this.endpoint.index,
        sceneId,
        dimmingDuration
      });
      return this.host.sendCommand(cc, this.commandOptions);
    }
    constructor() {
      super(...arguments);
      (0, import_tslib.__runInitializers)(this, _instanceExtraInitializers);
    }
  };
  return SceneActivationCCAPI2 = _classThis;
})();
let SceneActivationCC = (() => {
  let _classDecorators = [(0, import_CommandClassDecorators.commandClass)(import_core.CommandClasses["Scene Activation"]), (0, import_CommandClassDecorators.implementedVersion)(1), (0, import_CommandClassDecorators.ccValues)(import_CCValues_generated.SceneActivationCCValues)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_CommandClass.CommandClass;
  var SceneActivationCC2 = class extends _classSuper {
    static {
      __name(this, "SceneActivationCC");
    }
    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);
      SceneActivationCC2 = _classThis = _classDescriptor.value;
      if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
      (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
    }
  };
  return SceneActivationCC2 = _classThis;
})();
let SceneActivationCCSet = (() => {
  let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.SceneActivationCommand.Set), (0, import_CommandClassDecorators.useSupervision)(), (0, import_CommandClassDecorators.ccValueProperty)("sceneId", import_CCValues_generated.SceneActivationCCValues.sceneId), (0, import_CommandClassDecorators.ccValueProperty)("dimmingDuration", import_CCValues_generated.SceneActivationCCValues.dimmingDuration)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = SceneActivationCC;
  var SceneActivationCCSet2 = class extends _classSuper {
    static {
      __name(this, "SceneActivationCCSet");
    }
    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);
      SceneActivationCCSet2 = _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.sceneId = options.sceneId;
      this.dimmingDuration = import_core.Duration.from(options.dimmingDuration);
    }
    static from(raw, ctx) {
      (0, import_core.validatePayload)(raw.payload.length >= 1);
      const sceneId = raw.payload[0];
      (0, import_core.validatePayload)(sceneId >= 1, sceneId <= 255);
      let dimmingDuration;
      if (raw.payload.length >= 2) {
        dimmingDuration = import_core.Duration.parseSet(raw.payload[1]);
      }
      return new this({
        nodeId: ctx.sourceNodeId,
        sceneId,
        dimmingDuration
      });
    }
    sceneId;
    dimmingDuration;
    serialize(ctx) {
      this.payload = import_shared.Bytes.from([
        this.sceneId,
        this.dimmingDuration?.serializeSet() ?? 255
      ]);
      return super.serialize(ctx);
    }
    toLogEntry(ctx) {
      const message = { "scene id": this.sceneId };
      if (this.dimmingDuration != void 0) {
        message["dimming duration"] = this.dimmingDuration.toString();
      }
      return {
        ...super.toLogEntry(ctx),
        message
      };
    }
  };
  return SceneActivationCCSet2 = _classThis;
})();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  SceneActivationCC,
  SceneActivationCCAPI,
  SceneActivationCCSet,
  SceneActivationCCValues
});
//# sourceMappingURL=SceneActivationCC.js.map
