"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 CommandModel_exports = {};
__export(CommandModel_exports, {
  CommandModel: () => CommandModel
});
module.exports = __toCommonJS(CommandModel_exports);
var import_elements = require("../elements/index.js");
var import_ModelTraversal = require("../logic/ModelTraversal.js");
var import_Model = require("./Model.js");
var import_ValueModel = require("./ValueModel.js");
/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class CommandModel extends import_ValueModel.ValueModel {
  tag = import_elements.CommandElement.Tag;
  get fabricScoped() {
    return !!this.effectiveAccess.fabric;
  }
  get isRequest() {
    return this.direction === import_elements.CommandElement.Direction.Request;
  }
  get isResponse() {
    return this.direction === import_elements.CommandElement.Direction.Response;
  }
  get responseModel() {
    return new import_ModelTraversal.ModelTraversal().findResponse(this);
  }
  get effectiveDirection() {
    return this.direction ?? new import_ModelTraversal.ModelTraversal().findShadow(this)?.direction;
  }
  get requiredFields() {
    return { ...super.requiredFields, id: this.id };
  }
  /**
   * Commands may re-use the ID for request and response so identification requires the ID in conjunction with the
   * direction.
   */
  get discriminator() {
    if (this.direction === void 0) {
      if (this.name.endsWith("Response")) {
        return import_elements.CommandElement.Direction.Response;
      }
      return import_elements.CommandElement.Direction.Request;
    }
    return this.direction;
  }
  static {
    import_Model.Model.types[import_elements.CommandElement.Tag] = this;
  }
  static Tag = import_elements.CommandElement.Tag;
}
//# sourceMappingURL=CommandModel.js.map
