/**
 * @license
 * Copyright 2022-2024 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { CommandElement } from "../elements/index.js";
import { ModelTraversal } from "../logic/ModelTraversal.js";
import { Model } from "./Model.js";
import { ValueModel } from "./ValueModel.js";
class CommandModel extends ValueModel {
  tag = CommandElement.Tag;
  get fabricScoped() {
    return !!this.effectiveAccess.fabric;
  }
  get isRequest() {
    return this.direction === CommandElement.Direction.Request;
  }
  get isResponse() {
    return this.direction === CommandElement.Direction.Response;
  }
  get responseModel() {
    return new ModelTraversal().findResponse(this);
  }
  get effectiveDirection() {
    return this.direction ?? new ModelTraversal().findShadow(this)?.direction;
  }
  /**
   * 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 CommandElement.Direction.Response;
      }
      return CommandElement.Direction.Request;
    }
    return this.direction;
  }
  static {
    Model.types[CommandElement.Tag] = this;
  }
  static Tag = CommandElement.Tag;
}
export {
  CommandModel
};
//# sourceMappingURL=CommandModel.js.map
