"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 MicrowaveOvenModeServer_exports = {};
__export(MicrowaveOvenModeServer_exports, {
  MicrowaveOvenModeServer: () => MicrowaveOvenModeServer
});
module.exports = __toCommonJS(MicrowaveOvenModeServer_exports);
var import_mode_base = require("#behaviors/mode-base");
var import_microwave_oven_mode = require("#clusters/microwave-oven-mode");
var import_general = require("#general");
var import_MicrowaveOvenModeBehavior = require("./MicrowaveOvenModeBehavior.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class MicrowaveOvenModeServer extends import_MicrowaveOvenModeBehavior.MicrowaveOvenModeBehavior {
  initialize() {
    this.#assertSupportedModes();
    import_mode_base.ModeUtils.assertMode(this.state.supportedModes, this.state.currentMode);
    this.reactTo(this.events.currentMode$Changing, this.#assertMode);
  }
  #assertSupportedModes() {
    import_mode_base.ModeUtils.assertSupportedModes(this.state.supportedModes);
    if (this.state.supportedModes.filter(
      ({ modeTags }) => modeTags.some(({ value }) => value === import_microwave_oven_mode.MicrowaveOvenMode.ModeTag.Normal)
    ).length !== 1) {
      throw new import_general.ImplementationError("Provided supportedModes need to include exactly one Normal mode tag");
    }
    if (this.state.supportedModes.some(
      ({ modeTags }) => modeTags.some(({ value }) => value === import_microwave_oven_mode.MicrowaveOvenMode.ModeTag.Normal) && modeTags.some(({ value }) => value === import_microwave_oven_mode.MicrowaveOvenMode.ModeTag.Defrost)
    )) {
      throw new import_general.ImplementationError(
        "Provided supportedModes must not have Normal and Defrost mode tags together in one mode"
      );
    }
  }
  #assertMode(newMode) {
    import_mode_base.ModeUtils.assertMode(this.state.supportedModes, newMode);
  }
}
//# sourceMappingURL=MicrowaveOvenModeServer.js.map
